-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/no-shifted-scale
- Loading branch information
Showing
10 changed files
with
200 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule bindings
updated
14 files
+1 −1 | MINA_COMMIT | |
+131,930 −131,579 | compiled/node_bindings/o1js_node.bc.cjs | |
+1 −1 | compiled/node_bindings/o1js_node.bc.map | |
+678 −680 | compiled/node_bindings/plonk_wasm.cjs | |
+170 −170 | compiled/node_bindings/plonk_wasm.d.cts | |
+ − | compiled/node_bindings/plonk_wasm_bg.wasm | |
+312 −312 | compiled/node_bindings/plonk_wasm_bg.wasm.d.ts | |
+136 −136 | compiled/web_bindings/o1js_web.bc.js | |
+981 −981 | compiled/web_bindings/plonk_wasm.d.ts | |
+1,784 −1,785 | compiled/web_bindings/plonk_wasm.js | |
+ − | compiled/web_bindings/plonk_wasm_bg.wasm | |
+340 −340 | compiled/web_bindings/plonk_wasm_bg.wasm.d.ts | |
+9 −9 | crypto/constants.ts | |
+2 −2 | ocaml/lib/consistency_test.ml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Field } from '../field.js'; | ||
import { Gates } from '../gates.js'; | ||
|
||
export { rangeCheck3x12 }; | ||
|
||
function rangeCheck3x12(v0: Field, v1: Field, v2: Field) { | ||
// Checks that all three input values exist in the RANGE_CHECK_TABLE (tableId: 1) | ||
// v0, v1, v2 are used as the table keys | ||
// The table "values" (inputs no 3, 5, 7) are 0 because the table only has one column | ||
Gates.lookup( | ||
// table id | ||
Field.from(1), | ||
v0, | ||
Field.from(0), | ||
v1, | ||
Field.from(0), | ||
v2, | ||
Field.from(0) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { mod } from '../../../bindings/crypto/finite-field.js'; | ||
import { Field } from '../field.js'; | ||
import { ZkProgram } from '../../proof-system/zkprogram.js'; | ||
import { | ||
Spec, | ||
boolean, | ||
equivalentAsync, | ||
fieldWithRng, | ||
} from '../../testing/equivalent.js'; | ||
import { Random } from '../../testing/property.js'; | ||
import { assert } from '../gadgets/common.js'; | ||
import { Gadgets } from '../gadgets/gadgets.js'; | ||
import { constraintSystem, contains } from '../../testing/constraint-system.js'; | ||
|
||
let uint = (n: number | bigint): Spec<bigint, Field> => { | ||
return fieldWithRng(Random.bignat((1n << BigInt(n)) - 1n)); | ||
}; | ||
|
||
let maybeUint = (n: number | bigint): Spec<bigint, Field> => { | ||
let uint = Random.bignat((1n << BigInt(n)) - 1n); | ||
return fieldWithRng( | ||
Random.map(Random.oneOf(uint, uint.invalid), (x) => mod(x, Field.ORDER)) | ||
); | ||
}; | ||
|
||
let Lookup = ZkProgram({ | ||
name: 'lookup', | ||
methods: { | ||
three12Bit: { | ||
privateInputs: [Field, Field, Field], | ||
async method(v0: Field, v1: Field, v2: Field) { | ||
// Dummy range check to make sure the lookup table is initialized | ||
// It should never fail because 64 > 12 | ||
Gadgets.rangeCheck64(v0); | ||
Gadgets.rangeCheck3x12(v0, v1, v2); | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
// constraint system sanity check | ||
|
||
constraintSystem.fromZkProgram(Lookup, 'three12Bit', contains(['Lookup'])); | ||
|
||
await Lookup.compile(); | ||
|
||
await equivalentAsync( | ||
{ from: [uint(12), uint(12), maybeUint(12)], to: boolean }, | ||
{ runs: 3 } | ||
)( | ||
(x, y, z) => { | ||
assert(x < 1n << 12n); | ||
assert(y < 1n << 12n); | ||
assert(z < 1n << 12n); | ||
return true; | ||
}, | ||
async (x, y, z) => { | ||
let proof = await Lookup.three12Bit(x, y, z); | ||
return await Lookup.verify(proof); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.