-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Semi-regression (?): generic typeclass not matching #23547
Comments
!nim c type BigInt[N: static int] = object
raw: array[N, uint64]
func isZero(a: BigInt): bool =
discard
func isOne(a: BigInt): bool =
discard
type
QuadraticExt*[F] = object
## Quadratic Extension field
coords*: array[2, F]
CubicExt*[F] = object
## Cubic Extension field
coords*: array[3, F]
ExtensionField*[F] = QuadraticExt[F] or CubicExt[F]
func isOne*(a: ExtensionField): bool =
## Constant-time check if one
result = 1'u64
result = result and a.coords[0].isOne()
for i in 1 ..< a.coords.len:
result = result and a.coords[i].isZero()
func mulCheckSparse*(a: var QuadraticExt, b: static QuadraticExt) {.inline.} =
static:
debugEcho "QuadraticExt b: ", b is QuadraticExt # This is true
debugEcho "ExtensionField b: ", b is ExtensionField # This is false
when isOne(b).bool:
discard
else:
debugEcho "a *= b"
type EllipticCurve*[F] = object
x*, y*, z*: F
template sumImpl[F](
r: var EllipticCurve[F],
P, Q: EllipticCurve[F],
CoefA: typed) {.dirty.} =
when CoefA is int:
debugEcho "EC addition with int CoefA"
else:
var b = P.x
b.mulCheckSparse(CoefA)
func sum[F](
r: var EllipticCurve[F],
P, Q: EllipticCurve[F],
CoefA: static F) =
r.sumImpl(P, Q, CoefA)
## ----------------------------------
const h2c_const_ec = QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 1, 1, 1]),
BigInt[4](raw: [uint64 1, 1, 1, 1])]
)
var P = EllipticCurve[QuadraticExt[BigInt[4]]](
x: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
),
y: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
),
z: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
)
)
var Q = EllipticCurve[QuadraticExt[BigInt[4]]](
x: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
),
y: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
),
z: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
)
)
var R: EllipticCurve[QuadraticExt[BigInt[4]]]
R.sum(P, Q, h2c_const_ec) |
🐧 Linux bisect by @ringabout (member)devel 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("BigInt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("N"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("int")
),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("raw"),
nnkBracketExpr.newTree(
newIdentNode("array"),
newIdentNode("N"),
newIdentNode("uint64")
),
newEmptyNode()
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("isZero"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkFuncDef.newTree(
newIdentNode("isOne"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("QuadraticExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(2),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("CubicExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(3),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("ExtensionField")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkInfix.newTree(
newIdentNode("or"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
newIdentNode("F")
),
nnkBracketExpr.newTree(
newIdentNode("CubicExt"),
newIdentNode("F")
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("isOne")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("ExtensionField"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
newCommentStmtNode("Constant-time check if one"),
nnkAsgn.newTree(
newIdentNode("result"),
nnkUInt64Lit.newTree(
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newLit(0)
),
newIdentNode("isOne")
)
)
)
),
nnkForStmt.newTree(
newIdentNode("i"),
nnkInfix.newTree(
newIdentNode("..<"),
newLit(1),
nnkDotExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("len")
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("i")
),
newIdentNode("isZero")
)
)
)
)
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("mulCheckSparse")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("a"),
nnkVarTy.newTree(
newIdentNode("QuadraticExt")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("b"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("QuadraticExt")
),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("inline")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkStaticStmt.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("QuadraticExt b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("QuadraticExt")
)
),
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("ExtensionField b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("ExtensionField")
)
)
)
),
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
newIdentNode("isOne"),
newIdentNode("b")
),
newIdentNode("bool")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("a *= b")
)
)
)
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("EllipticCurve")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("x")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("y")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("z")
),
newIdentNode("F"),
newEmptyNode()
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("sumImpl"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
newIdentNode("typed"),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("dirty")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("CoefA"),
newIdentNode("int")
),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("EC addition with int CoefA")
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("b"),
newEmptyNode(),
nnkDotExpr.newTree(
newIdentNode("P"),
newIdentNode("x")
)
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("b"),
newIdentNode("mulCheckSparse")
),
newIdentNode("CoefA")
)
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("sum"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("F")
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("r"),
newIdentNode("sumImpl")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("CoefA")
)
)
),
newCommentStmtNode("----------------------------------"),
nnkConstSection.newTree(
nnkConstDef.newTree(
newIdentNode("h2c_const_ec"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("P"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("Q"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("R"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
newEmptyNode()
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("R"),
newIdentNode("sum")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("h2c_const_ec")
)
) stable 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("BigInt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("N"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("int")
),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("raw"),
nnkBracketExpr.newTree(
newIdentNode("array"),
newIdentNode("N"),
newIdentNode("uint64")
),
newEmptyNode()
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("isZero"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkFuncDef.newTree(
newIdentNode("isOne"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("QuadraticExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(2),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("CubicExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(3),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("ExtensionField")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkInfix.newTree(
newIdentNode("or"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
newIdentNode("F")
),
nnkBracketExpr.newTree(
newIdentNode("CubicExt"),
newIdentNode("F")
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("isOne")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("ExtensionField"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
newCommentStmtNode("Constant-time check if one"),
nnkAsgn.newTree(
newIdentNode("result"),
nnkUInt64Lit.newTree(
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newLit(0)
),
newIdentNode("isOne")
)
)
)
),
nnkForStmt.newTree(
newIdentNode("i"),
nnkInfix.newTree(
newIdentNode("..<"),
newLit(1),
nnkDotExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("len")
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("i")
),
newIdentNode("isZero")
)
)
)
)
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("mulCheckSparse")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("a"),
nnkVarTy.newTree(
newIdentNode("QuadraticExt")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("b"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("QuadraticExt")
),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("inline")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkStaticStmt.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("QuadraticExt b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("QuadraticExt")
)
),
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("ExtensionField b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("ExtensionField")
)
)
)
),
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
newIdentNode("isOne"),
newIdentNode("b")
),
newIdentNode("bool")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("a *= b")
)
)
)
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("EllipticCurve")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("x")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("y")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("z")
),
newIdentNode("F"),
newEmptyNode()
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("sumImpl"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
newIdentNode("typed"),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("dirty")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("CoefA"),
newIdentNode("int")
),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("EC addition with int CoefA")
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("b"),
newEmptyNode(),
nnkDotExpr.newTree(
newIdentNode("P"),
newIdentNode("x")
)
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("b"),
newIdentNode("mulCheckSparse")
),
newIdentNode("CoefA")
)
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("sum"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("F")
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("r"),
newIdentNode("sumImpl")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("CoefA")
)
)
),
newCommentStmtNode("----------------------------------"),
nnkConstSection.newTree(
nnkConstDef.newTree(
newIdentNode("h2c_const_ec"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("P"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("Q"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("R"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
newEmptyNode()
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("R"),
newIdentNode("sum")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("h2c_const_ec")
)
) 2.0.2 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("BigInt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("N"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("int")
),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("raw"),
nnkBracketExpr.newTree(
newIdentNode("array"),
newIdentNode("N"),
newIdentNode("uint64")
),
newEmptyNode()
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("isZero"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkFuncDef.newTree(
newIdentNode("isOne"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("QuadraticExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(2),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("CubicExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(3),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("ExtensionField")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkInfix.newTree(
newIdentNode("or"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
newIdentNode("F")
),
nnkBracketExpr.newTree(
newIdentNode("CubicExt"),
newIdentNode("F")
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("isOne")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("ExtensionField"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
newCommentStmtNode("Constant-time check if one"),
nnkAsgn.newTree(
newIdentNode("result"),
nnkUInt64Lit.newTree(
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newLit(0)
),
newIdentNode("isOne")
)
)
)
),
nnkForStmt.newTree(
newIdentNode("i"),
nnkInfix.newTree(
newIdentNode("..<"),
newLit(1),
nnkDotExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("len")
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("i")
),
newIdentNode("isZero")
)
)
)
)
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("mulCheckSparse")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("a"),
nnkVarTy.newTree(
newIdentNode("QuadraticExt")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("b"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("QuadraticExt")
),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("inline")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkStaticStmt.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("QuadraticExt b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("QuadraticExt")
)
),
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("ExtensionField b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("ExtensionField")
)
)
)
),
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
newIdentNode("isOne"),
newIdentNode("b")
),
newIdentNode("bool")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("a *= b")
)
)
)
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("EllipticCurve")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("x")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("y")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("z")
),
newIdentNode("F"),
newEmptyNode()
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("sumImpl"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
newIdentNode("typed"),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("dirty")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("CoefA"),
newIdentNode("int")
),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("EC addition with int CoefA")
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("b"),
newEmptyNode(),
nnkDotExpr.newTree(
newIdentNode("P"),
newIdentNode("x")
)
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("b"),
newIdentNode("mulCheckSparse")
),
newIdentNode("CoefA")
)
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("sum"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("F")
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("r"),
newIdentNode("sumImpl")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("CoefA")
)
)
),
newCommentStmtNode("----------------------------------"),
nnkConstSection.newTree(
nnkConstDef.newTree(
newIdentNode("h2c_const_ec"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("P"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("Q"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("R"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
newEmptyNode()
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("R"),
newIdentNode("sum")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("h2c_const_ec")
)
) 1.6.14 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("BigInt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("N"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("int")
),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("raw"),
nnkBracketExpr.newTree(
newIdentNode("array"),
newIdentNode("N"),
newIdentNode("uint64")
),
newEmptyNode()
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("isZero"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkFuncDef.newTree(
newIdentNode("isOne"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("QuadraticExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(2),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("CubicExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(3),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("ExtensionField")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkInfix.newTree(
newIdentNode("or"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
newIdentNode("F")
),
nnkBracketExpr.newTree(
newIdentNode("CubicExt"),
newIdentNode("F")
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("isOne")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("ExtensionField"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
newCommentStmtNode("Constant-time check if one"),
nnkAsgn.newTree(
newIdentNode("result"),
nnkUInt64Lit.newTree(
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newLit(0)
),
newIdentNode("isOne")
)
)
)
),
nnkForStmt.newTree(
newIdentNode("i"),
nnkInfix.newTree(
newIdentNode("..<"),
newLit(1),
nnkDotExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("len")
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("i")
),
newIdentNode("isZero")
)
)
)
)
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("mulCheckSparse")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("a"),
nnkVarTy.newTree(
newIdentNode("QuadraticExt")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("b"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("QuadraticExt")
),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("inline")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkStaticStmt.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("QuadraticExt b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("QuadraticExt")
)
),
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("ExtensionField b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("ExtensionField")
)
)
)
),
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
newIdentNode("isOne"),
newIdentNode("b")
),
newIdentNode("bool")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("a *= b")
)
)
)
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("EllipticCurve")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("x")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("y")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("z")
),
newIdentNode("F"),
newEmptyNode()
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("sumImpl"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
newIdentNode("typed"),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("dirty")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("CoefA"),
newIdentNode("int")
),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("EC addition with int CoefA")
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("b"),
newEmptyNode(),
nnkDotExpr.newTree(
newIdentNode("P"),
newIdentNode("x")
)
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("b"),
newIdentNode("mulCheckSparse")
),
newIdentNode("CoefA")
)
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("sum"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("F")
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("r"),
newIdentNode("sumImpl")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("CoefA")
)
)
),
newCommentStmtNode("----------------------------------"),
nnkConstSection.newTree(
nnkConstDef.newTree(
newIdentNode("h2c_const_ec"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("P"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("Q"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("R"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
newEmptyNode()
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("R"),
newIdentNode("sum")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("h2c_const_ec")
)
) 1.4.8 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("BigInt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("N"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("int")
),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("raw"),
nnkBracketExpr.newTree(
newIdentNode("array"),
newIdentNode("N"),
newIdentNode("uint64")
),
newEmptyNode()
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("isZero"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkFuncDef.newTree(
newIdentNode("isOne"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("QuadraticExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(2),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("CubicExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(3),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("ExtensionField")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkInfix.newTree(
newIdentNode("or"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
newIdentNode("F")
),
nnkBracketExpr.newTree(
newIdentNode("CubicExt"),
newIdentNode("F")
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("isOne")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("ExtensionField"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
newCommentStmtNode("Constant-time check if one"),
nnkAsgn.newTree(
newIdentNode("result"),
nnkUInt64Lit.newTree(
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newLit(0)
),
newIdentNode("isOne")
)
)
)
),
nnkForStmt.newTree(
newIdentNode("i"),
nnkInfix.newTree(
newIdentNode("..<"),
newLit(1),
nnkDotExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("len")
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("i")
),
newIdentNode("isZero")
)
)
)
)
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("mulCheckSparse")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("a"),
nnkVarTy.newTree(
newIdentNode("QuadraticExt")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("b"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("QuadraticExt")
),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("inline")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkStaticStmt.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("QuadraticExt b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("QuadraticExt")
)
),
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("ExtensionField b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("ExtensionField")
)
)
)
),
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
newIdentNode("isOne"),
newIdentNode("b")
),
newIdentNode("bool")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("a *= b")
)
)
)
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("EllipticCurve")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("x")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("y")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("z")
),
newIdentNode("F"),
newEmptyNode()
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("sumImpl"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
newIdentNode("typed"),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("dirty")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("CoefA"),
newIdentNode("int")
),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("EC addition with int CoefA")
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("b"),
newEmptyNode(),
nnkDotExpr.newTree(
newIdentNode("P"),
newIdentNode("x")
)
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("b"),
newIdentNode("mulCheckSparse")
),
newIdentNode("CoefA")
)
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("sum"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("F")
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("r"),
newIdentNode("sumImpl")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("CoefA")
)
)
),
newCommentStmtNode("----------------------------------"),
nnkConstSection.newTree(
nnkConstDef.newTree(
newIdentNode("h2c_const_ec"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("P"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("Q"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("R"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
newEmptyNode()
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("R"),
newIdentNode("sum")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("h2c_const_ec")
)
) 1.2.18 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("BigInt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("N"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("int")
),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("raw"),
nnkBracketExpr.newTree(
newIdentNode("array"),
newIdentNode("N"),
newIdentNode("uint64")
),
newEmptyNode()
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("isZero"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkFuncDef.newTree(
newIdentNode("isOne"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("QuadraticExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(2),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("CubicExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(3),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("ExtensionField")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkInfix.newTree(
newIdentNode("or"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
newIdentNode("F")
),
nnkBracketExpr.newTree(
newIdentNode("CubicExt"),
newIdentNode("F")
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("isOne")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("ExtensionField"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
newCommentStmtNode("Constant-time check if one"),
nnkAsgn.newTree(
newIdentNode("result"),
nnkUInt64Lit.newTree(
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newLit(0)
),
newIdentNode("isOne")
)
)
)
),
nnkForStmt.newTree(
newIdentNode("i"),
nnkInfix.newTree(
newIdentNode("..<"),
newLit(1),
nnkDotExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("len")
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("i")
),
newIdentNode("isZero")
)
)
)
)
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("mulCheckSparse")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("a"),
nnkVarTy.newTree(
newIdentNode("QuadraticExt")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("b"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("QuadraticExt")
),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("inline")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkStaticStmt.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("QuadraticExt b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("QuadraticExt")
)
),
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("ExtensionField b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("ExtensionField")
)
)
)
),
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
newIdentNode("isOne"),
newIdentNode("b")
),
newIdentNode("bool")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("a *= b")
)
)
)
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("EllipticCurve")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("x")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("y")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("z")
),
newIdentNode("F"),
newEmptyNode()
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("sumImpl"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
newIdentNode("typed"),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("dirty")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("CoefA"),
newIdentNode("int")
),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("EC addition with int CoefA")
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("b"),
newEmptyNode(),
nnkDotExpr.newTree(
newIdentNode("P"),
newIdentNode("x")
)
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("b"),
newIdentNode("mulCheckSparse")
),
newIdentNode("CoefA")
)
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("sum"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("F")
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("r"),
newIdentNode("sumImpl")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("CoefA")
)
)
),
newCommentStmtNode("----------------------------------"),
nnkConstSection.newTree(
nnkConstDef.newTree(
newIdentNode("h2c_const_ec"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("P"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("Q"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("R"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
newEmptyNode()
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("R"),
newIdentNode("sum")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("h2c_const_ec")
)
) 1.0.10 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("BigInt"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("N"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("int")
),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("raw"),
nnkBracketExpr.newTree(
newIdentNode("array"),
newIdentNode("N"),
newIdentNode("uint64")
),
newEmptyNode()
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("isZero"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkFuncDef.newTree(
newIdentNode("isOne"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("BigInt"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("QuadraticExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(2),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("CubicExt")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("coords")
),
nnkBracketExpr.newTree(
newIdentNode("array"),
newLit(3),
newIdentNode("F")
),
newEmptyNode()
)
)
)
),
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("ExtensionField")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkInfix.newTree(
newIdentNode("or"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
newIdentNode("F")
),
nnkBracketExpr.newTree(
newIdentNode("CubicExt"),
newIdentNode("F")
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("isOne")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newIdentNode("bool"),
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("ExtensionField"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
newCommentStmtNode("Constant-time check if one"),
nnkAsgn.newTree(
newIdentNode("result"),
nnkUInt64Lit.newTree(
)
),
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newLit(0)
),
newIdentNode("isOne")
)
)
)
),
nnkForStmt.newTree(
newIdentNode("i"),
nnkInfix.newTree(
newIdentNode("..<"),
newLit(1),
nnkDotExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("len")
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
newIdentNode("result"),
nnkInfix.newTree(
newIdentNode("and"),
newIdentNode("result"),
nnkCall.newTree(
nnkDotExpr.newTree(
nnkBracketExpr.newTree(
nnkDotExpr.newTree(
newIdentNode("a"),
newIdentNode("coords")
),
newIdentNode("i")
),
newIdentNode("isZero")
)
)
)
)
)
)
)
),
nnkFuncDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("mulCheckSparse")
),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("a"),
nnkVarTy.newTree(
newIdentNode("QuadraticExt")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("b"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("QuadraticExt")
),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("inline")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkStaticStmt.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("QuadraticExt b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("QuadraticExt")
)
),
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("ExtensionField b: "),
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("b"),
newIdentNode("ExtensionField")
)
)
)
),
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkDotExpr.newTree(
nnkCall.newTree(
newIdentNode("isOne"),
newIdentNode("b")
),
newIdentNode("bool")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("a *= b")
)
)
)
)
)
),
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("EllipticCurve")
),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("x")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("y")
),
nnkPostfix.newTree(
newIdentNode("*"),
newIdentNode("z")
),
newIdentNode("F"),
newEmptyNode()
)
)
)
)
),
nnkTemplateDef.newTree(
newIdentNode("sumImpl"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
newIdentNode("typed"),
newEmptyNode()
)
),
nnkPragma.newTree(
newIdentNode("dirty")
),
newEmptyNode(),
nnkStmtList.newTree(
nnkWhenStmt.newTree(
nnkElifBranch.newTree(
nnkInfix.newTree(
newIdentNode("is"),
newIdentNode("CoefA"),
newIdentNode("int")
),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("debugEcho"),
newLit("EC addition with int CoefA")
)
)
),
nnkElse.newTree(
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("b"),
newEmptyNode(),
nnkDotExpr.newTree(
newIdentNode("P"),
newIdentNode("x")
)
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("b"),
newIdentNode("mulCheckSparse")
),
newIdentNode("CoefA")
)
)
)
)
)
),
nnkFuncDef.newTree(
newIdentNode("sum"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("F"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("r"),
nnkVarTy.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
)
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("P"),
newIdentNode("Q"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
newIdentNode("F")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("CoefA"),
nnkCommand.newTree(
newIdentNode("static"),
newIdentNode("F")
),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("r"),
newIdentNode("sumImpl")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("CoefA")
)
)
),
newCommentStmtNode("----------------------------------"),
nnkConstSection.newTree(
nnkConstDef.newTree(
newIdentNode("h2c_const_ec"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(1),
newLit(1),
newLit(1)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("P"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("Q"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("x"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("y"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
),
nnkExprColonExpr.newTree(
newIdentNode("z"),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
),
nnkExprColonExpr.newTree(
newIdentNode("coords"),
nnkBracket.newTree(
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
),
nnkExprColonExpr.newTree(
newIdentNode("raw"),
nnkBracket.newTree(
nnkCommand.newTree(
newIdentNode("uint64"),
newLit(1)
),
newLit(2),
newLit(3),
newLit(4)
)
)
)
)
)
)
)
)
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("R"),
nnkBracketExpr.newTree(
newIdentNode("EllipticCurve"),
nnkBracketExpr.newTree(
newIdentNode("QuadraticExt"),
nnkBracketExpr.newTree(
newIdentNode("BigInt"),
newLit(4)
)
)
),
newEmptyNode()
)
),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("R"),
newIdentNode("sum")
),
newIdentNode("P"),
newIdentNode("Q"),
newIdentNode("h2c_const_ec")
)
) Stats
🤖 Bug found in |
Bisecting with the full Constantine lib. The regression happened in 5e20e93 / #22828 that was trying to fix #22826 I assume #22828 fixed a caching issue that happened to make my full-blown library work and that fix surfaced the long-standing underlying bug. I also assume that the test case @alaviss mentioned being broken is related import macros
type
A[T] = T
macro eqTyp(x, y: typed) =
# NOTE: the `or` is due to sameType not being commutative: https://github.com/nim-lang/Nim/issues/18867
doAssert sameType(x, y) or sameType(y, x), "nim does not consider these to be the same!"
eqTyp(A[float], float) |
* ci: temporarily deactivate non-working CI pending nim-lang/Nim#23547 and nim-lang/nightlies#82 * remove macos from matrix include as well
… regression reverted nim-lang/Nim@767a901
This compiles: type BigInt[N: static int] = object
raw: array[N, uint64]
func isZero(a: BigInt): bool =
discard
func isOne(a: BigInt): bool =
discard
type
QuadraticExt*[F] = object
## Quadratic Extension field
coords*: array[2, F]
CubicExt*[F] = object
## Cubic Extension field
coords*: array[3, F]
ExtensionField*[F] = QuadraticExt[F] | CubicExt[F]
func isOne*[T](a: ExtensionField[T]): bool =
## Constant-time check if one
result = a.coords[0].isOne()
for i in 1 ..< a.coords.len:
result = result and a.coords[i].isZero()
template mulCheckSparse*[T](a: var QuadraticExt[T], b: QuadraticExt[T]) =
static:
debugEcho "QuadraticExt b: ", b is QuadraticExt # This is true
debugEcho "ExtensionField b: ", b is ExtensionField # This is false
when isOne(b).bool:
discard
else:
debugEcho "a *= b"
type EllipticCurve*[F] = object
x*, y*, z*: F
template sumImpl[F](
r: var EllipticCurve[F],
P, Q: EllipticCurve[F],
CoefA: F) {.dirty.} =
when CoefA is int:
debugEcho "EC addition with int CoefA"
else:
var b = P.x
b.mulCheckSparse(CoefA)
func sum[F](
r: var EllipticCurve[F],
P, Q: EllipticCurve[F],
CoefA: static F) =
r.sumImpl(P, Q, CoefA)
## ----------------------------------
const h2c_const_ec = QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 1, 1, 1]),
BigInt[4](raw: [uint64 1, 1, 1, 1])]
)
var P = EllipticCurve[QuadraticExt[BigInt[4]]](
x: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
),
y: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
),
z: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
)
)
var Q = EllipticCurve[QuadraticExt[BigInt[4]]](
x: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
),
y: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
),
z: QuadraticExt[BigInt[4]](
coords: [BigInt[4](raw: [uint64 1, 2, 3, 4]),
BigInt[4](raw: [uint64 1, 2, 3, 4])]
)
)
var R: EllipticCurve[QuadraticExt[BigInt[4]]]
R.sum(P, Q, h2c_const_ec)
|
… regression reverted nim-lang/Nim@767a901
… regression reverted nim-lang/Nim@767a901
… regression reverted nim-lang/Nim@767a901 (#393)
So the only difference is func isOne*(a: ExtensionField): bool =
## Constant-time check if one
result = 1'u64
result = result and a.coords[0].isOne()
for i in 1 ..< a.coords.len:
result = result and a.coords[i].isZero() was changed to func isOne*[T](a: ExtensionField[T]): bool =
## Constant-time check if one
result = a.coords[0].isOne()
for i in 1 ..< a.coords.len:
result = result and a.coords[i].isZero() ? |
Ah there was the change back to templates as well. |
Real issue seems to be that type
A[T] = object
x: T
proc mulCheckSparse[F](dummy: var A[F], x: static A[F]) =
static:
echo "mulCheckSparse: ", typeof(dummy), ", ", typeof(x) # when generic params not specified: A[system.int], A
template sumImpl(x: typed) =
static:
echo "sumImpl: ", typeof(x) # A
var a = A[int]()
mulCheckSparse(a, x) # fails here
proc sum[T](x: static T) =
static:
echo "sum: ", typeof(x) # A[system.int]
sumImpl(x)
const a = A[int]()
sum[A[int]](a) |
This adds Constantine to the important packages. Release announcements: - https://forum.nim-lang.org/t/11935 - https://github.com/mratsim/constantine/releases/tag/v0.1.0 Unfortunately at the moment I'm in a conundrum. - Constantine cannot compile on devel due to #23547 - The workaround is changing ```Nim func mulCheckSparse*(a: var QuadraticExt, b: static QuadraticExt) {.inline.} = ``` to ```Nim template mulCheckSparse*(a: var QuadraticExt, b: QuadraticExt) = ``` but this does not compile on v2.0.8 due to `gensym` issues despite #23716 ![image](https://github.com/nim-lang/Nim/assets/22738317/21c875d7-512f-4c21-8547-d12534e93a58). i.e. as mentioned in the issue #23711 there is another gensym bug within templates that was fixed in devel but not the v2.0.x series and that is not fixed by #23716
Fix #23547 Tested locally with the included test, the test from constantine and the original issue.
Original issue: mratsim/constantine#373
It can be reproduced in its full environment with:
git clone https://github.com/mratsim/constantine cd constantine git checkout 976c8bb nim c --verbosity:0 --hints:off --warnings:off --outdir:build tests/t_hash_to_curve_random.nim
In the original issue, Nim v2.0.4 works but latest version-2-0 branch (v2.0.5) doesn't.
Now here is a single file reproduction. Surprisingly this fails on both Nim v2.0.4 and latest version-2-0
The text was updated successfully, but these errors were encountered: