Skip to content

Commit 1ab8ea6

Browse files
author
Ahmed Elghareeb
committed
docs: updates code snippets in the composite proof section
1 parent 527d592 commit 1ab8ea6

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

README.md

+19-12
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ to reveal his last name and city, but not any other attributes while proving tha
454454
const messages: Uint8Array[] = [...];
455455

456456
// Public values
457-
const parasm: SignatureParamsG1;
458-
const pk: BBSPlusPublicKeyG2;
457+
const params: BBSSignatureParams;
458+
const pk: BBSPublicKey;
459459

460460
// The signature
461-
const sig: SignatureG1 = ...;
461+
const sig: BBSSignature = ...;
462462

463463
// Prover prepares the attributes he wants to disclose, i.e. attribute index 2 and 4 (indexing is 0-based), and the ones he wants to hide.
464464
const revealedMsgIndices: Set<number> = new Set();
@@ -467,21 +467,22 @@ revealedMsgIndices.add(4);
467467

468468
// revealedMsgs are the attributes disclosed to the verifier
469469
const revealedMsgs: Map<number, Uint8Array> = new Map();
470-
revealedMsgs.set(i, messages[2]);
471-
revealedMsgs.set(i, messages[4]);
470+
revealedMsgs.set(2, messages[2]);
472471

473472
// unrevealedMsgs are the attributes hidden from the verifier
474473
const unrevealedMsgs: Map<number, Uint8Array> = new Map();
475-
unrevealedMsgs.set(i, messages[0]);
476-
unrevealedMsgs.set(i, messages[1]);
477-
unrevealedMsgs.set(i, messages[3]);
474+
unrevealedMsgs.set(0, messages[0]);
475+
unrevealedMsgs.set(1, messages[1]);
476+
unrevealedMsgs.set(3, messages[3]);
478477
```
479478

480479
Since there is only 1 kind of proof, i.e. the knowledge of BBS signature and the signed attributes, there would be only 1 `Statement`.
481480

482481
```ts
483-
const statement1 = Statement.bbsPlusSignature(params, pk, revealedMsgs, true);
482+
import { Statement, Statements } from '@docknetwork/crypto-wasm-ts'
483+
484484
// Create a BBS signature, true indicates that attributes/messages are arbitrary bytes and should be encoded first
485+
const statement1 = Statement.bbsSignatureProverConstantTime(paramsDeterministc, revealedMsgs, true);
485486
const statements = new Statements();
486487
statements.add(statement1);
487488

@@ -494,23 +495,29 @@ Both the prover and verifier should independently construct this `ProofSpec`. No
494495
other conditions on the witnesses and thus its empty
495496

496497
```ts
498+
import { ProofSpec, MetaStatements } from '@docknetwork/crypto-wasm-ts';
499+
497500
const ms = new MetaStatements();
498-
const proofSpec = new ProofSpecG1(statements, ms, [], context);
501+
const proofSpec = new ProofSpec(statements, ms, [], context);
499502
```
500503

501504
Prover creates `Witness` using the signature and hidden attributes
502505

503506
```ts
504-
const witness1 = Witness.bbsPlusSignature(sig, unrevealedMsgs, true);
507+
import { Witness, Witnesses } from '@docknetwork/crypto-wasm-ts';
508+
509+
const witness1 = Witness.bbsSignatureConstantTime(sig, unrevealedMsgs, true);
505510
const witnesses = new Witnesses();
506511
witnesses.add(witness1);
507512
```
508513

509514
Prover now uses the `ProofSpec` to create the proof. To ensure that the prover is not replaying, i.e. reusing a proof created by someone else, the verifier can request the prover to include its provided nonce in the proof.
510515

511516
```ts
517+
import { CompositeProof } from '@docknetwork/crypto-wasm-ts';
518+
512519
const nonce = stringToBytes('a unique nonce given by verifier');
513-
const proof = CompositeProofG1.generate(proofSpec, witnesses, nonce);
520+
const proof = CompositeProof.generate(proofSpec, witnesses, nonce);
514521
```
515522

516523
Verifier can now verify this proof. Note that the verifier does not and must not receive `ProofSpec` from prover, it

0 commit comments

Comments
 (0)