Skip to content

Commit c9df4f9

Browse files
authored
Merge pull request #20 from reclaimprotocol/remove-proofjson
[FEAT] remove proofJson and move proof one level up for simplicity
2 parents 688f4bd + 60e33a3 commit c9df4f9

File tree

9 files changed

+14
-20
lines changed

9 files changed

+14
-20
lines changed

bin/gnark/linux-arm64-libprove.so

0 Bytes
Binary file not shown.

bin/gnark/linux-arm64-libverify.so

0 Bytes
Binary file not shown.

bin/gnark/linux-x86_64-libprove.so

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

gnark/libraries/core_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestFullChaCha20(t *testing.T) {
100100

101101
inParams := &verifier.InputVerifyParams{
102102
Cipher: inputParams.Cipher,
103-
Proof: outParams.Proof.ProofJson,
103+
Proof: outParams.Proof,
104104
PublicSignals: signals,
105105
}
106106
inBuf, err := json.Marshal(inParams)
@@ -145,7 +145,7 @@ func TestFullAES256(t *testing.T) {
145145

146146
inParams := &verifier.InputVerifyParams{
147147
Cipher: inputParams.Cipher,
148-
Proof: outParams.Proof.ProofJson,
148+
Proof: outParams.Proof,
149149
PublicSignals: signals,
150150
}
151151
inBuf, _ := json.Marshal(inParams)
@@ -189,7 +189,7 @@ func TestFullAES128(t *testing.T) {
189189

190190
inParams := &verifier.InputVerifyParams{
191191
Cipher: inputParams.Cipher,
192-
Proof: outParams.Proof.ProofJson,
192+
Proof: outParams.Proof,
193193
PublicSignals: signals,
194194
}
195195
inBuf, _ := json.Marshal(inParams)
@@ -329,7 +329,7 @@ func TestFullChaCha20OPRF(t *testing.T) {
329329

330330
inParams := &verifier.InputVerifyParams{
331331
Cipher: inputParams.Cipher,
332-
Proof: outParams.Proof.ProofJson,
332+
Proof: outParams.Proof,
333333
PublicSignals: publicSignals,
334334
}
335335
inBuf, _ := json.Marshal(inParams)
@@ -470,7 +470,7 @@ func TestFullAES128OPRF(t *testing.T) {
470470

471471
inParams := &verifier.InputVerifyParams{
472472
Cipher: inputParams.Cipher,
473-
Proof: outParams.Proof.ProofJson,
473+
Proof: outParams.Proof,
474474
PublicSignals: publicSignals,
475475
}
476476
inBuf, _ := json.Marshal(inParams)
@@ -610,7 +610,7 @@ func TestFullAES256OPRF(t *testing.T) {
610610

611611
inParams := &verifier.InputVerifyParams{
612612
Cipher: inputParams.Cipher,
613-
Proof: outParams.Proof.ProofJson,
613+
Proof: outParams.Proof,
614614
PublicSignals: publicSignals,
615615
}
616616
inBuf, _ := json.Marshal(inParams)

gnark/libraries/prover/impl/library.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,8 @@ var provers = map[string]*ProverParams{
6666
},
6767
}
6868

69-
type Proof struct {
70-
ProofJson []uint8 `json:"proofJson"`
71-
}
72-
7369
type OutputParams struct {
74-
Proof Proof `json:"proof"`
70+
Proof []uint8 `json:"proof"`
7571
PublicSignals []uint8 `json:"publicSignals"`
7672
}
7773

@@ -152,9 +148,7 @@ func Prove(params []byte) []byte {
152148
proof, ciphertext := prover.Prove(inputParams)
153149

154150
res, er := json.Marshal(&OutputParams{
155-
Proof: Proof{
156-
ProofJson: proof,
157-
},
151+
Proof: proof,
158152
PublicSignals: ciphertext,
159153
})
160154
if er != nil {

js/src/gnark/operator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export function makeGnarkZkOperator({
2323
async groth16Prove(witness, logger) {
2424
const lib = await initGnark(logger)
2525
const {
26-
proof: { proofJson },
26+
proof,
2727
publicSignals
2828
} = await executeGnarkFnAndGetJson(lib.prove, witness)
2929
return {
30-
proof: Base64.toUint8Array(proofJson),
30+
proof: Base64.toUint8Array(proof),
3131
publicSignals: Array.from(Base64.toUint8Array(publicSignals))
3232
}
3333
},

js/src/gnark/toprf.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export function makeGnarkOPRFOperator({
2525
async groth16Prove(witness, logger) {
2626
const lib = await initGnark(logger)
2727
const {
28-
proof: { proofJson }
28+
proof
2929
} = await executeGnarkFnAndGetJson(lib.prove, witness)
30-
return { proof: Base64.toUint8Array(proofJson) }
30+
return { proof: Base64.toUint8Array(proof) }
3131
},
3232
async groth16Verify(publicSignals, proof, logger) {
3333
const lib = await initGnark(logger)

js/src/gnark/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ export async function executeGnarkFnAndGetJson(
209209
) {
210210
const { free, koffi } = await globalGnarkLib!
211211
const res = executeGnarkFn(fn, jsonInput)
212-
const proofJson = Buffer.from(
212+
const proof = Buffer.from(
213213
koffi.decode(res.r0, 'unsigned char', res.r1)
214214
).toString()
215215
free(res.r0) // Avoid memory leak!
216-
return JSON.parse(proofJson)
216+
return JSON.parse(proof)
217217
}

0 commit comments

Comments
 (0)