Skip to content

Commit

Permalink
Precompiles scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
ilitteri committed Jun 23, 2023
1 parent fc42e54 commit fcd4c44
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
43 changes: 43 additions & 0 deletions EcAdd.yul
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
object "EcAdd" {
code { }
object "EcAdd_deployed" {
code {
////////////////////////////////////////////////////////////////
// CONSTANTS
////////////////////////////////////////////////////////////////

function ZERO() -> zero {
zero := 0x0
}

function ONE() -> one {
one := 0x1
}

// Retrieve the coordinates from the calldata
let x1 := calldataload(0)
let y1 := calldataload(32)
let x2 := calldataload(64)
let y2 := calldataload(96)

// Retrieve the curve parameters from the calldata
let a := calldataload(128)
let b := calldataload(160)

// Retrieve the field modulus from the calldata
let p := calldataload(192)

// Ensure p is valid

// Ensure that the points are in the curve

// Ensure that the point is in the right subgroup (if needed)

// Add the points

// Ensure that the resulting point is in the curve

// Return the result
}
}
}
44 changes: 44 additions & 0 deletions EcMul.yul
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
object "EcMul" {
code { }
object "EcMul_deployed" {
code {
////////////////////////////////////////////////////////////////
// CONSTANTS
////////////////////////////////////////////////////////////////

function ZERO() -> zero {
zero := 0x0
}

function ONE() -> one {
one := 0x1
}

// Retrieve the coordinates from the calldata
let x1 := calldataload(0)
let y1 := calldataload(32)

// Retrieve the scalar from the calldata
let m := calldataload(64)

// Retrieve the curve parameters from the calldata
let a := calldataload(128)
let b := calldataload(160)

// Retrieve the field modulus from the calldata
let p := calldataload(192)

// Ensure p is valid

// Ensure that the point is in the curve

// Ensure that the point is in the right subgroup (if needed)

// Multiply the point by the scalar

// Check that the resulting point is in the curve

// Return the result
}
}
}
12 changes: 12 additions & 0 deletions EcPairing.yul
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object "EcPairing" {
code { }
object "EcPairing_deployed" {
code {
// Note: this check assumes that the curve is bn256, this is not final and could not be right in the future.
if not(eq(mod(calldatasize(), 0xc0), 0)) {
// Bad pairing input
revert(0,0)
}
}
}
}

0 comments on commit fcd4c44

Please sign in to comment.