@@ -454,11 +454,11 @@ to reveal his last name and city, but not any other attributes while proving tha
454
454
const messages: Uint8Array [] = [... ];
455
455
456
456
// Public values
457
- const parasm : SignatureParamsG1 ;
458
- const pk: BBSPlusPublicKeyG2 ;
457
+ const params : BBSSignatureParams ;
458
+ const pk: BBSPublicKey ;
459
459
460
460
// The signature
461
- const sig: SignatureG1 = ... ;
461
+ const sig: BBSSignature = ... ;
462
462
463
463
// 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.
464
464
const revealedMsgIndices: Set <number > = new Set ();
@@ -467,21 +467,22 @@ revealedMsgIndices.add(4);
467
467
468
468
// revealedMsgs are the attributes disclosed to the verifier
469
469
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 ]);
472
471
473
472
// unrevealedMsgs are the attributes hidden from the verifier
474
473
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 ]);
478
477
```
479
478
480
479
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 ` .
481
480
482
481
``` ts
483
- const statement1 = Statement .bbsPlusSignature (params , pk , revealedMsgs , true );
482
+ import { Statement , Statements } from ' @docknetwork/crypto-wasm-ts'
483
+
484
484
// 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 );
485
486
const statements = new Statements ();
486
487
statements .add (statement1 );
487
488
@@ -494,23 +495,29 @@ Both the prover and verifier should independently construct this `ProofSpec`. No
494
495
other conditions on the witnesses and thus its empty
495
496
496
497
``` ts
498
+ import { ProofSpec , MetaStatements } from ' @docknetwork/crypto-wasm-ts' ;
499
+
497
500
const ms = new MetaStatements ();
498
- const proofSpec = new ProofSpecG1 (statements , ms , [], context );
501
+ const proofSpec = new ProofSpec (statements , ms , [], context );
499
502
```
500
503
501
504
Prover creates ` Witness ` using the signature and hidden attributes
502
505
503
506
``` 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 );
505
510
const witnesses = new Witnesses ();
506
511
witnesses .add (witness1 );
507
512
```
508
513
509
514
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.
510
515
511
516
``` ts
517
+ import { CompositeProof } from ' @docknetwork/crypto-wasm-ts' ;
518
+
512
519
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 );
514
521
```
515
522
516
523
Verifier can now verify this proof. Note that the verifier does not and must not receive ` ProofSpec ` from prover, it
0 commit comments