@@ -85,47 +85,51 @@ describe('identity encryption', () => {
8585 } ) ;
8686} ) ;
8787
88- describe ( 'identity ownership proofs' , ( ) => {
89- it ( 'should generate and verify ownership proofs' , async ( ) => {
90- // generate a random private key to simulate a user wallet
91- const account = privateKeyToAccount ( bytesToHex ( randomBytes ( 32 ) ) as Hex ) ;
92-
93- const signer = accountSigner ( account ) ;
94- const accountAddress = await signer . getAddress ( ) ;
95- const keys = createIdentityKeys ( ) ;
96- const { accountProof, keyProof } = await proveIdentityOwnership ( signer , accountAddress , keys ) ;
97-
98- const valid = await verifyIdentityOwnership ( accountAddress , keys . signaturePublicKey , accountProof , keyProof ) ;
99- expect ( valid ) . toBe ( true ) ;
100- } ) ;
101- it ( 'should fail to verify ownership proofs with invalid proofs' , async ( ) => {
102- // generate a random private key to simulate a user wallet
103- const account = privateKeyToAccount ( bytesToHex ( randomBytes ( 32 ) ) as Hex ) ;
104- const signer = accountSigner ( account ) ;
105- const accountAddress = await signer . getAddress ( ) ;
106- const keys = createIdentityKeys ( ) ;
107- const { accountProof, keyProof } = await proveIdentityOwnership ( signer , accountAddress , keys ) ;
108-
109- // Create invalid proofs using a different account
110- const account2 = privateKeyToAccount ( bytesToHex ( randomBytes ( 32 ) ) as Hex ) ;
111- const signer2 = accountSigner ( account2 ) ;
112- const accountAddress2 = await signer2 . getAddress ( ) ;
113- const keys2 = createIdentityKeys ( ) ;
114- const { accountProof : accountProof2 , keyProof : keyProof2 } = await proveIdentityOwnership (
115- signer2 ,
116- accountAddress2 ,
117- keys2 ,
118- ) ;
119-
120- // Check with invalid wallet proof, key proof, and with both invalid proofs
121- const valid = await verifyIdentityOwnership ( accountAddress , keys . signaturePublicKey , accountProof2 , keyProof ) ;
122- expect ( valid ) . toBe ( false ) ;
123-
124- const valid2 = await verifyIdentityOwnership ( accountAddress , keys . signaturePublicKey , accountProof , keyProof2 ) ;
125- expect ( valid2 ) . toBe ( false ) ;
126-
127- const valid3 = await verifyIdentityOwnership ( accountAddress , keys . signaturePublicKey , accountProof2 , keyProof2 ) ;
128-
129- expect ( valid3 ) . toBe ( false ) ;
130- } ) ;
131- } ) ;
88+ // TODO: add tests for identity ownership proofs
89+ // These are not so easy to test now because we need to interact with a blockchain RPC
90+ // to verify smart account signatures.
91+ //
92+ // describe('identity ownership proofs', () => {
93+ // it('should generate and verify ownership proofs', async () => {
94+ // // generate a random private key to simulate a user wallet
95+ // const account = privateKeyToAccount(bytesToHex(randomBytes(32)) as Hex);
96+
97+ // const signer = accountSigner(account);
98+ // const accountAddress = await signer.getAddress();
99+ // const keys = createIdentityKeys();
100+ // const { accountProof, keyProof } = await proveIdentityOwnership(signer, accountAddress, keys);
101+
102+ // const valid = await verifyIdentityOwnership(accountAddress, keys.signaturePublicKey, accountProof, keyProof);
103+ // expect(valid).toBe(true);
104+ // });
105+ // it('should fail to verify ownership proofs with invalid proofs', async () => {
106+ // // generate a random private key to simulate a user wallet
107+ // const account = privateKeyToAccount(bytesToHex(randomBytes(32)) as Hex);
108+ // const signer = accountSigner(account);
109+ // const accountAddress = await signer.getAddress();
110+ // const keys = createIdentityKeys();
111+ // const { accountProof, keyProof } = await proveIdentityOwnership(signer, accountAddress, keys);
112+
113+ // // Create invalid proofs using a different account
114+ // const account2 = privateKeyToAccount(bytesToHex(randomBytes(32)) as Hex);
115+ // const signer2 = accountSigner(account2);
116+ // const accountAddress2 = await signer2.getAddress();
117+ // const keys2 = createIdentityKeys();
118+ // const { accountProof: accountProof2, keyProof: keyProof2 } = await proveIdentityOwnership(
119+ // signer2,
120+ // accountAddress2,
121+ // keys2,
122+ // );
123+
124+ // // Check with invalid wallet proof, key proof, and with both invalid proofs
125+ // const valid = await verifyIdentityOwnership(accountAddress, keys.signaturePublicKey, accountProof2, keyProof);
126+ // expect(valid).toBe(false);
127+
128+ // const valid2 = await verifyIdentityOwnership(accountAddress, keys.signaturePublicKey, accountProof, keyProof2);
129+ // expect(valid2).toBe(false);
130+
131+ // const valid3 = await verifyIdentityOwnership(accountAddress, keys.signaturePublicKey, accountProof2, keyProof2);
132+
133+ // expect(valid3).toBe(false);
134+ // });
135+ // });
0 commit comments