Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aztec/key-store

Package Overview
Dependencies
Maintainers
6
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aztec/key-store - npm Package Compare versions

Comparing version 0.16.7 to 0.16.8

7

dest/test_key_store.d.ts
import { GrumpkinPrivateKey } from '@aztec/circuits.js';
import { Grumpkin } from '@aztec/circuits.js/barretenberg';
import { AztecKVStore } from '@aztec/kv-store';
import { KeyStore, PublicKey } from '@aztec/types';

@@ -9,6 +10,6 @@ /**

export declare class TestKeyStore implements KeyStore {
#private;
private curve;
private accounts;
constructor(curve: Grumpkin);
addAccount(privKey: GrumpkinPrivateKey): PublicKey;
constructor(curve: Grumpkin, database: AztecKVStore);
addAccount(privKey: GrumpkinPrivateKey): Promise<PublicKey>;
createAccount(): Promise<PublicKey>;

@@ -15,0 +16,0 @@ getAccounts(): Promise<PublicKey[]>;

@@ -0,1 +1,4 @@

var _TestKeyStore_keys;
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
import { GrumpkinScalar, Point } from '@aztec/circuits.js';
import { ConstantKeyPair } from './key_pair.js';

@@ -7,23 +10,20 @@ /**

export class TestKeyStore {
constructor(curve) {
constructor(curve, database) {
this.curve = curve;
this.accounts = [];
_TestKeyStore_keys.set(this, void 0);
__classPrivateFieldSet(this, _TestKeyStore_keys, database.createMap('key_store'), "f");
}
addAccount(privKey) {
async addAccount(privKey) {
const keyPair = ConstantKeyPair.fromPrivateKey(this.curve, privKey);
// check if private key has already been used
const account = this.accounts.find(a => a.getPublicKey().equals(keyPair.getPublicKey()));
if (account) {
return account.getPublicKey();
}
this.accounts.push(keyPair);
await __classPrivateFieldGet(this, _TestKeyStore_keys, "f").setIfNotExists(keyPair.getPublicKey().toString(), keyPair.getPrivateKey().toBuffer());
return keyPair.getPublicKey();
}
createAccount() {
async createAccount() {
const keyPair = ConstantKeyPair.random(this.curve);
this.accounts.push(keyPair);
return Promise.resolve(keyPair.getPublicKey());
await __classPrivateFieldGet(this, _TestKeyStore_keys, "f").set(keyPair.getPublicKey().toString(), keyPair.getPrivateKey().toBuffer());
return keyPair.getPublicKey();
}
getAccounts() {
return Promise.resolve(this.accounts.map(a => a.getPublicKey()));
const range = Array.from(__classPrivateFieldGet(this, _TestKeyStore_keys, "f").keys());
return Promise.resolve(range.map(key => Point.fromString(key)));
}

@@ -43,9 +43,10 @@ getAccountPrivateKey(pubKey) {

getAccount(pubKey) {
const account = this.accounts.find(a => a.getPublicKey().equals(pubKey));
if (!account) {
const privKey = __classPrivateFieldGet(this, _TestKeyStore_keys, "f").get(pubKey.toString());
if (!privKey) {
throw new Error('Unknown account.\nSee docs for context: https://docs.aztec.network/dev_docs/contracts/common_errors#unknown-contract-error');
}
return account;
return ConstantKeyPair.fromPrivateKey(this.curve, GrumpkinScalar.fromBuffer(privKey));
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF9rZXlfc3RvcmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdGVzdF9rZXlfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUVoRDs7O0dBR0c7QUFDSCxNQUFNLE9BQU8sWUFBWTtJQUV2QixZQUFvQixLQUFlO1FBQWYsVUFBSyxHQUFMLEtBQUssQ0FBVTtRQUQzQixhQUFRLEdBQWMsRUFBRSxDQUFDO0lBQ0ssQ0FBQztJQUVoQyxVQUFVLENBQUMsT0FBMkI7UUFDM0MsTUFBTSxPQUFPLEdBQUcsZUFBZSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLE9BQU8sQ0FBQyxDQUFDO1FBRXBFLDZDQUE2QztRQUM3QyxNQUFNLE9BQU8sR0FBRyxJQ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sQ0FBQyxhQUFhLEVBQUUsQ0FBQyxDQUFDO0lBQ2xELENBQUM7SUFFRDs7Ozs7OztPQU9HO0lBQ0ssVUFBVSxDQUFDLE1BQWlCO1FBQ2xDLE1BQU0sT0FBTyxHQUFHLHVCQUFBLElBQUksMEJBQU0sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUM7UUFDbEQsSUFBSSxDQUFDLE9BQU8sRUFBRTtZQUNaLE1BQU0sSUFBSSxLQUFLLENBQ2IsNEhBQTRILENBQzdILENBQUM7U0FDSDtRQUNELE9BQU8sZUFBZSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLGNBQWMsQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztJQUN4RixDQUFDO0NBQ0YifQ==
{
"name": "@aztec/key-store",
"version": "0.16.7",
"version": "0.16.8",
"type": "module",

@@ -33,5 +33,6 @@ "exports": "./dest/index.js",

"dependencies": {
"@aztec/circuits.js": "0.16.7",
"@aztec/foundation": "0.16.7",
"@aztec/types": "0.16.7",
"@aztec/circuits.js": "0.16.8",
"@aztec/foundation": "0.16.8",
"@aztec/kv-store": "0.16.8",
"@aztec/types": "0.16.8",
"tslib": "^2.4.0"

@@ -38,0 +39,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc