-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add oracle call to retrieve public key for a given address (#1027)
* Adds oracle call to fetch the public key for an address * Placeholder for address validation * Temporarily remove sanity check
- Loading branch information
1 parent
32e9d26
commit 5d9e254
Showing
21 changed files
with
251 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { AztecNode } from '@aztec/aztec-node'; | ||
import { AztecAddress, CircuitsWasm, Fr } from '@aztec/circuits.js'; | ||
import { computeContractAddressFromPartial } from '@aztec/circuits.js/abis'; | ||
import { Grumpkin } from '@aztec/circuits.js/barretenberg'; | ||
import { ConstantKeyPair, TestKeyStore } from '@aztec/key-store'; | ||
import { randomBytes } from 'crypto'; | ||
import { MockProxy, mock } from 'jest-mock-extended'; | ||
import { MemoryDB } from '../database/memory_db.js'; | ||
import { AztecRPCServer } from './aztec_rpc_server.js'; | ||
|
||
describe('AztecRpcServer', function () { | ||
let wasm: CircuitsWasm; | ||
let keyStore: TestKeyStore; | ||
let db: MemoryDB; | ||
let node: MockProxy<AztecNode>; | ||
let rpcServer: AztecRPCServer; | ||
|
||
beforeEach(async () => { | ||
keyStore = new TestKeyStore(await Grumpkin.new()); | ||
node = mock<AztecNode>(); | ||
db = new MemoryDB(); | ||
rpcServer = new AztecRPCServer(keyStore, node, db); | ||
wasm = await CircuitsWasm.get(); | ||
}); | ||
|
||
it('registers a public key in the db when adding a new account', async () => { | ||
const keyPair = ConstantKeyPair.random(await Grumpkin.new()); | ||
const pubKey = keyPair.getPublicKey(); | ||
const partialAddress = Fr.random(); | ||
const address = computeContractAddressFromPartial(wasm, pubKey, partialAddress); | ||
|
||
await rpcServer.addAccount(await keyPair.getPrivateKey(), address, partialAddress); | ||
expect(await db.getPublicKey(address)).toEqual([pubKey, partialAddress]); | ||
}); | ||
|
||
// TODO(#1007) | ||
it.skip('refuses to add an account with incorrect address for given partial address and pubkey', async () => { | ||
const privateKey = randomBytes(32); | ||
const partialAddress = Fr.random(); | ||
const address = AztecAddress.random(); | ||
|
||
await expect(rpcServer.addAccount(privateKey, address, partialAddress)).rejects.toThrowError(/cannot be derived/); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.