refactor: switch to goldilocks curve

This commit is contained in:
Chance
2023-10-10 20:06:35 -05:00
parent 96b7cb66fb
commit df40ec897e
5 changed files with 30 additions and 3 deletions

View File

@@ -29,8 +29,10 @@ jobs:
name: Fetch rstark wasm
command: |
cd ..
wget https://github.com/vimwitch/rstark/releases/download/alpha-1/rstark.tar.gz
wget https://github.com/vimwitch/rstark/releases/download/alpha-1-goldilocks/rstark.tar.gz
tar -xzf rstark.tar.gz
mkdir rstark
mv pkg rstark
- run:
name: Install Packages
command: npm i

View File

@@ -3,9 +3,14 @@ import { MultiPolynomial } from 'starkstark/src/MultiPolynomial.mjs'
import { Polynomial } from 'starkstark/src/Polynomial.mjs'
import { ScalarField } from 'starkstark/src/ScalarField.mjs'
// export const field = new ScalarField(
// 1n + 407n * (1n << 119n), // 0xCB800000000000000000000000000001
// 85408008396924667383611388730472331217n
// )
export const field = new ScalarField(
1n + 407n * (1n << 119n), // 0xCB800000000000000000000000000001
85408008396924667383611388730472331217n
18446744069414584321n,
2717n
)
// compile an assembly file to a set of STARK constraints

BIN
test/epochKeyLite_main.r1cs Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -13,6 +13,26 @@ function serializeBigint(v) {
return out
}
test.skip('should compile and prove unirep epoch key r1cs', async t => {
const input = Array(7).fill(2n)
const asm = await compileR1cs('test/epochKeyLite_main.r1cs', input)
const compiled = compile(asm)
const trace = buildTrace(compiled.program)
const proof = wasm.prove({
transition_constraints: compiled.constraints.map(v => v.serialize()),
boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]),
trace: trace.map(t => t.map(v => serializeBigint(v))),
})
wasm.verify(proof, {
trace_len: trace.length,
register_count: compiled.program.registerCount,
transition_constraints: compiled.constraints.map(v => v.serialize()),
boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]),
})
t.pass()
})
test('should compile and prove r1cs', async t => {
const input = [
12n,