From 2f4399015219682eb9483a4149f1eab4c9a7a9d0 Mon Sep 17 00:00:00 2001 From: Karuizawa-Kei Date: Fri, 20 Sep 2024 09:13:41 +0700 Subject: [PATCH] clean code --- build/src/Bridge.d.ts | 12 +- build/src/Bridge.js | 107 ++++++--------- build/src/Bridge.js.map | 2 +- build/src/Bridge.test.js | 59 ++++---- build/src/Bridge.test.js.map | 2 +- build/src/ValidatorManager.d.ts | 26 ++-- build/src/ValidatorManager.js | 84 ++++-------- build/src/ValidatorManager.js.map | 2 +- build/src/deploy/000_deploy_all.js | 48 +++---- build/src/deploy/000_deploy_all.js.map | 2 +- build/src/deploy/006_unlock_token.js | 63 +++++---- build/src/deploy/006_unlock_token.js.map | 2 +- src/Bridge.test.ts | 67 +++++----- src/Bridge.ts | 163 ++++++++++------------- src/ValidatorManager.ts | 67 ++++------ src/deploy/000_deploy_all.ts | 54 ++------ src/deploy/006_unlock_token.ts | 71 +++++----- 17 files changed, 350 insertions(+), 481 deletions(-) diff --git a/build/src/Bridge.d.ts b/build/src/Bridge.d.ts index 5090de4..119623c 100644 --- a/build/src/Bridge.d.ts +++ b/build/src/Bridge.d.ts @@ -1,5 +1,4 @@ -import { PublicKey, SmartContract, State, UInt64, Bool, DeployArgs, Field } from 'o1js'; -import { Secp256k1, Ecdsa, Bytes32, Bytes256 } from './ecdsa/ecdsa.js'; +import { PublicKey, SmartContract, State, UInt64, Bool, DeployArgs, Field, Signature } from 'o1js'; declare const UnlockEvent_base: (new (value: { receiver: PublicKey; tokenAddress: PublicKey; @@ -209,10 +208,9 @@ export declare class Bridge extends SmartContract { changeManager(newManager: PublicKey): Promise; changeValidatorManager(validatorManager: PublicKey): Promise; lock(amount: UInt64, address: Field, tokenAddr: PublicKey): Promise; - unlock(amount: UInt64, receiver: PublicKey, id: UInt64, tokenAddr: PublicKey, useSig1: Bool, signature_1: Ecdsa, validator_1: Secp256k1, useSig2: Bool, signature_2: Ecdsa, validator_2: Secp256k1, useSig3: Bool, signature_3: Ecdsa, validator_3: Secp256k1): Promise; - isValidator(validator: Secp256k1, useSig: Bool): Bool; - validateValidator(useSig1: Bool, validator_1: Secp256k1, useSig2: Bool, validator_2: Secp256k1, useSig3: Bool, validator_3: Secp256k1): void; - validateSig(msg: Bytes256, signature: Ecdsa, validator: Secp256k1, useSig: Bool): Promise; - validateMsg(message: Bytes32, signature: Ecdsa, publicKey: Secp256k1): Promise; + unlock(amount: UInt64, receiver: PublicKey, id: UInt64, tokenAddr: PublicKey, useSig1: Bool, validator1: PublicKey, sig1: Signature, useSig2: Bool, validator2: PublicKey, sig2: Signature, useSig3: Bool, validator3: PublicKey, sig3: Signature): Promise; + validateValidator(useSig1: Bool, validator1: PublicKey, useSig2: Bool, validator2: PublicKey, useSig3: Bool, validator3: PublicKey): Promise; + validateSig(msg: Field[], signature: Signature, validator: PublicKey, useSig: Bool): Promise; + verifyMsg(publicKey: PublicKey, msg: Field[], sig: Signature): Promise; } export {}; diff --git a/build/src/Bridge.js b/build/src/Bridge.js index 985f247..b6298d1 100644 --- a/build/src/Bridge.js +++ b/build/src/Bridge.js @@ -7,9 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -import { PublicKey, SmartContract, State, UInt64, method, state, Struct, Bool, Provable, Field, MerkleMap } from 'o1js'; +import { PublicKey, SmartContract, State, UInt64, method, state, Struct, Bool, Provable, Field, Signature } from 'o1js'; import { FungibleToken } from "mina-fungible-token"; -import { Secp256k1, Ecdsa, Bytes256 } from './ecdsa/ecdsa.js'; import { ValidatorManager } from './ValidatorManager.js'; import { Manager } from './Manager.js'; class UnlockEvent extends Struct({ @@ -83,72 +82,52 @@ export class Bridge extends SmartContract { await token.burn(this.sender.getAndRequireSignature(), amount); this.emitEvent("Lock", new LockEvent(this.sender.getAndRequireSignature(), address, amount, tokenAddr)); } - async unlock(amount, receiver, id, tokenAddr, useSig1, signature_1, validator_1, useSig2, signature_2, validator_2, useSig3, signature_3, validator_3) { + async unlock(amount, receiver, id, tokenAddr, useSig1, validator1, sig1, useSig2, validator2, sig2, useSig3, validator3, sig3) { const managerZkapp = new Manager(this.manager.getAndRequireEquals()); managerZkapp.isAdmin(this.sender.getAndRequireSignature()); - let msg = Bytes256.fromString(`unlock receiver = ${receiver.toFields} amount = ${amount.toFields} tokenAddr = ${tokenAddr.toFields}`); - this.validateValidator(useSig1, validator_1, useSig2, validator_2, useSig3, validator_3); - this.validateSig(msg, signature_1, validator_1, useSig1); - this.validateSig(msg, signature_2, validator_2, useSig2); - this.validateSig(msg, signature_3, validator_3, useSig3); + const msg = [ + ...receiver.toFields(), + ...amount.toFields(), + ...tokenAddr.toFields(), + ]; + this.validateValidator(useSig1, validator1, useSig2, validator2, useSig3, validator3); + this.validateSig(msg, sig1, validator1, useSig1); + this.validateSig(msg, sig2, validator2, useSig2); + this.validateSig(msg, sig3, validator3, useSig3); const token = new FungibleToken(tokenAddr); await token.mint(receiver, amount); this.emitEvent("Unlock", new UnlockEvent(receiver, tokenAddr, amount, id)); } - isValidator(validator, useSig) { - const validatorManager = new ValidatorManager(this.validatorManager.getAndRequireEquals()); - let isValid = Bool(false); - Provable.asProver(() => { - const x = Field.from(validator.x.toBigInt()); - const y = Field.from(validator.y.toBigInt()); - isValid = useSig.toBoolean() ? validatorManager.isValidator(x, y) : Bool(false); - Provable.log("isValid", isValid); - }); - return isValid; - } - validateValidator(useSig1, validator_1, useSig2, validator_2, useSig3, validator_3) { + async validateValidator(useSig1, validator1, useSig2, validator2, useSig3, validator3) { let count = UInt64.from(0); - Provable.asProver(async () => { - const map = new MerkleMap(); - const checkValidator = (useSig, validator) => { - if (useSig.toBoolean()) { - const x = Field.from(validator.x.toBigInt()); - const y = Field.from(validator.y.toBigInt()); - let yMap = map.get(x); - yMap.assertNotEquals(y); - map.set(x, y); - } - }; - checkValidator(useSig1, validator_1); - checkValidator(useSig2, validator_2); - checkValidator(useSig3, validator_3); - }); - if (this.isValidator(validator_1, useSig1).toBoolean()) { - count = count.add(1); - } - if (this.isValidator(validator_2, useSig2).toBoolean()) { - count = count.add(1); - } - if (this.isValidator(validator_3, useSig3).toBoolean()) { - count = count.add(1); - } - Provable.log("count", count); - count.assertGreaterThanOrEqual(this.threshold.getAndRequireEquals(), "Not enough validators"); + const zero = Field.from(0); + const falseB = Bool(false); + const trueB = Bool(true); + const validatorManager = new ValidatorManager(this.validatorManager.getAndRequireEquals()); + const validateIndex = async (validator, useSig) => { + const index = await validatorManager.getValidatorIndex(validator); + const isGreaterThanZero = index.greaterThan(zero); + let isOk = Provable.if(useSig, Provable.if(isGreaterThanZero, trueB, falseB), trueB); + isOk.assertTrue("Public key not found in validators"); + }; + const notDupValidator12 = Provable.if(useSig1.and(useSig2), Provable.if(validator1.equals(validator2), falseB, trueB), trueB); + const notDupValidator13 = Provable.if(useSig1.and(useSig3), Provable.if(validator1.equals(validator3), falseB, trueB), trueB); + const notDupValidator23 = Provable.if(useSig2.and(useSig3), Provable.if(validator2.equals(validator3), falseB, trueB), trueB); + const isDuplicate = Provable.if(notDupValidator12.and(notDupValidator13).and(notDupValidator23), falseB, trueB); + isDuplicate.assertFalse("Duplicate validator keys"); + count = Provable.if(useSig1, count.add(1), count); + count = Provable.if(useSig2, count.add(1), count); + count = Provable.if(useSig3, count.add(1), count); + count.assertGreaterThanOrEqual(this.threshold.getAndRequireEquals(), "Not reached threshold"); } async validateSig(msg, signature, validator, useSig) { - let isValid = Bool(false); - Provable.asProver(async () => { - if (useSig.toBoolean()) { - isValid = await this.validateMsg(msg, signature, validator); - Provable.log("validateMsg isValid", isValid); - isValid.assertTrue("Invalid signature for validator"); - } - }); + let isValidSig = signature.verify(validator, msg); + const isValid = Provable.if(useSig, isValidSig, Bool(true)); + isValid.assertTrue("Invalid signature"); } - async validateMsg(message, signature, publicKey) { - let proof = await signature.verifyV2(message, publicKey); - Provable.log("proof", proof); - return proof; + async verifyMsg(publicKey, msg, sig) { + const isOk = await sig.verify(publicKey, msg); + Provable.log("isOk", isOk.toString()); } } __decorate([ @@ -203,14 +182,14 @@ __decorate([ UInt64, PublicKey, Bool, - Ecdsa, - Secp256k1, + PublicKey, + Signature, Bool, - Ecdsa, - Secp256k1, + PublicKey, + Signature, Bool, - Ecdsa, - Secp256k1]), + PublicKey, + Signature]), __metadata("design:returntype", Promise) ], Bridge.prototype, "unlock", null); //# sourceMappingURL=Bridge.js.map \ No newline at end of file diff --git a/build/src/Bridge.js.map b/build/src/Bridge.js.map index b858cda..99d0d1a 100644 --- a/build/src/Bridge.js.map +++ b/build/src/Bridge.js.map @@ -1 +1 @@ -{"version":3,"file":"Bridge.js","sourceRoot":"","sources":["../../src/Bridge.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,SAAS,EACT,aAAa,EACb,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EAEN,IAAI,EAGJ,QAAQ,EACR,KAAK,EAML,SAAS,EAGV,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAkC,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,WAAY,SAAQ,MAAM,CAAC;IAC/B,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,SAAS;IACvB,MAAM,EAAE,MAAM;IACd,EAAE,EAAE,MAAM;CACX,CAAC;IACA,YACI,QAAmB,EACnB,YAAuB,EACvB,MAAc,EACd,EAAU;QAEZ,KAAK,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;CACF;AAED,MAAM,SAAU,SAAQ,MAAM,CAAC;IAC7B,MAAM,EAAE,S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tE;AAEa;IAAb,MAAM;;qCACG,MAAM;QACJ,SAAS;QACf,MAAM;QACC,SAAS;QACX,IAAI;QACA,KAAK;QACL,SAAS;QACb,IAAI;QACA,KAAK;QACL,SAAS;QACb,IAAI;QACA,KAAK;QACL,SAAS;;oCAqBvB"} \ No newline at end of file +{"version":3,"file":"Bridge.js","sourceRoot":"","sources":["../../src/Bridge.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,SAAS,EACT,aAAa,EACb,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,IAAI,EAEJ,QAAQ,EACR,KAAK,EAEL,SAAS,EACV,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,WAAY,SAAQ,MAAM,CAAC;IAC/B,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,SAAS;IACvB,MAAM,EAAE,MAAM;IACd,EAAE,EAAE,MAAM;CACX,CAAC;IACA,YACE,QAAmB,EACnB,YAAuB,EACvB,MAAc,EACd,EAAU;QAEV,KAAK,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;CACF;AAED,MAAM,SAAU,SAAQ,MAAM,CAAC;IAC7B,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,MAAM;IACd,YAAY,EAAE,SAAS;CACxB,CAAC;IACA,YAAY,MAAiB,EAAE,OAAc,EAAE,MAAc,EAAE,YAAuB;QACpF,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAED,MAAM,OAAO,MAAO,SAAQ,aAAa;IAAzC;;QACiB,cAAS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CAAC,SAAS,CAAC,SAAoB,EAAE,GAAY,EAAE,GAAc;QACvE,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAC9C,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxC,CAAC;CAEF;AA3JC;IAAC,KAAK,CAAC,MAAM,CAAC;;yCAA6B;AAC3C;IAAC,KAAK,CAAC,MAAM,CAAC;;yCAA6B;AAC3C;IAAC,KAAK,CAAC,MAAM,CAAC;;yCAA6B;AAC3C;IAAC,KAAK,CAAC,SAAS,CAAC;;gDAAuC;AACxD;IAAC,KAAK,CAAC,SAAS,CAAC;;uCAA8B;AAoBjC;IAAb,MAAM;;qCAAqC,MAAM,EAAgB,MAAM;;6CAWvE;AAEa;IAAb,MAAM;;qCAAiC,SAAS;;2CAMhD;AAEa;IAAb,MAAM;;qCAAgD,SAAS;;oDAK/D;AAEa;IAAb,MAAM;;qCAAoB,MAAM,EAAW,KAAK,EAAa,SAAS;;kCAWtE;AAEa;IAAb,MAAM;;qCACG,MAAM;QACJ,SAAS;QACf,MAAM;QACC,SAAS;QACX,IAAI;QACD,SAAS;QACf,SAAS;QACN,IAAI;QACD,SAAS;QACf,SAAS;QACN,IAAI;QACD,SAAS;QACf,SAAS;;oCAwBhB"} \ No newline at end of file diff --git a/build/src/Bridge.test.js b/build/src/Bridge.test.js index 66bedb3..a7bb420 100644 --- a/build/src/Bridge.test.js +++ b/build/src/Bridge.test.js @@ -1,7 +1,7 @@ -import { AccountUpdate, Bool, Encoding, Field, Mina, PrivateKey, UInt64, UInt8 } from 'o1js'; +import { AccountUpdate, Bool, Encoding, Field, Mina, PrivateKey, Signature, UInt64, UInt8 } from 'o1js'; import { Bridge } from './Bridge'; import { FungibleToken, FungibleTokenAdmin } from 'mina-fungible-token'; -import { Bytes256, Ecdsa, Secp256k1 } from './ecdsa/ecdsa'; +import { Secp256k1 } from './ecdsa/ecdsa'; import { ValidatorManager } from './ValidatorManager'; import { Manager } from './Manager'; const proofsEnabled = false; @@ -12,23 +12,12 @@ describe("Bridge", () => { const userPubkey = Local.testAccounts[0]; const normalUserPrivkey = Local.testAccounts[2].key; const normalUserPubkey = Local.testAccounts[2]; - const validatorPrivateKey1 = Secp256k1.Scalar.random(); - const validatorPublicKey1 = Secp256k1.generator.scale(validatorPrivateKey1); - const validatorPrivateKey2 = Secp256k1.Scalar.random(); - const validatorPublicKey2 = Secp256k1.generator.scale(validatorPrivateKey2); - const validatorPrivateKey3 = Secp256k1.Scalar.random(); - const validatorPublicKey3 = Secp256k1.generator.scale(validatorPrivateKey3); - const validatorPrivateKeyGen = Secp256k1.Scalar.from(BigInt('123456789012345678901234567890123456789')); - const validatorPublicKeyGen = Secp256k1.generator.scale(validatorPrivateKeyGen); - console.log("🚀 ~ describe ~ validatorPublicKeyGen:", validatorPublicKeyGen); - console.log("🚀 ~ describe ~ validatorPublicKeyGen x :", validatorPublicKeyGen.x.toBigInt().toString()); - console.log("🚀 ~ describe ~ validatorPublicKeyGen y :", validatorPublicKeyGen.y.toBigInt().toString()); - const x1 = Field.from(validatorPublicKey1.x.toBigInt().toString()); - const y1 = Field.from(validatorPublicKey1.y.toBigInt().toString()); - let x2 = Field.from(validatorPublicKey2.x.toBigInt().toString()); - let y2 = Field.from(validatorPublicKey2.y.toBigInt().toString()); - let x3 = Field.from(validatorPublicKey3.x.toBigInt().toString()); - let y3 = Field.from(validatorPublicKey3.y.toBigInt().toString()); + const validator1Privkey = Local.testAccounts[3].key; + const validator1Pubkey = Local.testAccounts[3]; + const validator2Privkey = Local.testAccounts[4].key; + const validator2Pubkey = Local.testAccounts[4]; + const validator3Privkey = Local.testAccounts[5].key; + const validator3Pubkey = Local.testAccounts[5]; const adminContractPrivkey = PrivateKey.random(); const adminContractPubkey = adminContractPrivkey.toPublicKey(); const tokenPrivkey = PrivateKey.random(); @@ -96,12 +85,9 @@ describe("Bridge", () => { let validatorManagerTx = await Mina.transaction(userPubkey, async () => { AccountUpdate.fundNewAccount(userPubkey, 1); await validatorZkapp.deploy({ - _val1X: x1, - _val1Y: y1, - _val2X: x2, - _val2Y: y2, - _val3X: x3, - _val3Y: y3, + _validator1: validator1Pubkey, + _validator2: validator2Pubkey, + _validator3: validator3Pubkey, _manager: managerPubkey, }); }); @@ -191,12 +177,16 @@ describe("Bridge", () => { // }); // console.log("publicKey_1:", publicKey_1); let amount = UInt64.from(10); - let msg = Bytes256.fromString(`unlock receiver = ${normalUserPubkey.toFields} amount = ${amount.toFields} tokenAddr = ${tokenPubkey.toFields}`); - let signature = Ecdsa.sign(msg.toBytes(), validatorPrivateKey1.toBigInt()); - let signature1 = Ecdsa.sign(msg.toBytes(), privateKey_1.toBigInt()); + const msg = [ + ...normalUserPubkey.toFields(), + ...amount.toFields(), + ...tokenPubkey.toFields(), + ]; + let signature = Signature.create(userPrivkey, msg); + let signature1 = Signature.create(normalUserPrivkey, msg); + ; let unlockTx = await Mina.transaction(userPubkey, async () => { - // AccountUpdate.fundNewAccount(userPubkey, 1); - await bridgeZkapp.unlock(amount, normalUserPubkey, UInt64.from(1), tokenPubkey, Bool(true), signature, validatorPublicKey1, Bool(false), signature, validatorPublicKey1, Bool(false), signature, validatorPublicKey1); + await bridgeZkapp.unlock(amount, normalUserPubkey, UInt64.from(1), tokenPubkey, Bool(true), userPubkey, signature, Bool(false), userPubkey, signature, Bool(false), userPubkey, signature); }); unlockTx.sign([userPrivkey, bridgePrivkey]); await unlockTx.prove(); @@ -211,6 +201,15 @@ describe("Bridge", () => { await lockTx.send(); const afterLockBalance = await token.getBalanceOf(normalUserPubkey); console.log("after lock balance:", afterLockBalance.toString()); + // const msg: Field[] = [Field.from(1), Field.from(2), Field.from(3)]; + // const msg1: Field[] = [Field.from(1), Field.from(2), Field.from(4)]; + // const sig = Signature.create(normalUserPrivkey, msg); + // let lockTx = await Mina.transaction(userPubkey, async () => { + // await bridgeZkapp.verifyMsg(normalUserPubkey, msg1, sig); + // }) + // lockTx.sign([userPrivkey]) + // await lockTx.prove() + // await lockTx.send() // const check = await validatorZkapp.isValidator(publicKey_1) // console.log("��� ~ it ~ check:", check.toString()); }); diff --git a/build/src/Bridge.test.js.map b/build/src/Bridge.test.js.map index 165b712..6051192 100644 --- a/build/src/Bridge.test.js.map +++ b/build/src/Bridge.test.js.map @@ -1 +1 @@ -{"version":3,"file":"Bridge.test.js","sourceRoot":"","sources":["../../src/Bridge.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAAE,IAAI,EAAoC,QAAQ,EAAgB,KAAK,EAAoB,IAAI,EAAE,UAAU,EAAuB,MAAM,EAAE,KAAK,EAAgB,MAAM,MAAM,CAAA;AAC1M,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAS,KAAK,EAAkB,SAAS,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,MAAM,aAAa,GAAG,KAAK,CAAA;AAE3B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,aAAa,EAAE,CAAC,CAAA;AAC3D,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAG7B,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IAEpB,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9C,MAAM,UAAU,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAEzC,MAAM,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACnD,MAAM,gBAAgB,GAAG,KAAK,CAAC,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E,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhE,sEAAsE;QACtE,uEAAuE;QACvE,wDAAwD;QAIxD,gEAAgE;QAChE,gEAAgE;QAChE,KAAK;QACL,6BAA6B;QAC7B,uBAAuB;QACvB,sBAAsB;QAGtB,8DAA8D;QAC9D,sDAAsD;IAC1D,CAAC,CAAC,CAAA;AAGN,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/build/src/ValidatorManager.d.ts b/build/src/ValidatorManager.d.ts index 93feb11..22f9403 100644 --- a/build/src/ValidatorManager.d.ts +++ b/build/src/ValidatorManager.d.ts @@ -1,23 +1,17 @@ import { SmartContract, State, Bool, DeployArgs, Field, PublicKey } from 'o1js'; export declare class ValidatorManager extends SmartContract { - validator1X: State; - validator1Y: State; - validator2X: State; - validator2Y: State; - validator3X: State; - validator3Y: State; + validator1: State; + validator2: State; + validator3: State; manager: State; deploy(args: DeployArgs & { - _val1X: Field; - _val1Y: Field; - _val2X: Field; - _val2Y: Field; - _val3X: Field; - _val3Y: Field; + _validator1: PublicKey; + _validator2: PublicKey; + _validator3: PublicKey; _manager: PublicKey; }): Promise; - isValidator(xKey: Field, yValue: Field): Bool; - getValidatorIndex(xKey: Field, yValue: Field): Field; - compareValidators(x1: Field, y1: Field, x2: Field, y2: Field): Bool; - changeValidator(xKey1: Field, yKey1: Field, xKey2: Field, yKey2: Field, xKey3: Field, yKey3: Field): Promise; + isValidator(p: PublicKey): Bool; + getValidatorIndex(p: PublicKey): Field; + compareValidators(p1: PublicKey, p2: PublicKey): Bool; + changeValidator(validator1: PublicKey, validator2: PublicKey, validator3: PublicKey): Promise; } diff --git a/build/src/ValidatorManager.js b/build/src/ValidatorManager.js index 99ad195..ad46362 100644 --- a/build/src/ValidatorManager.js +++ b/build/src/ValidatorManager.js @@ -7,83 +7,58 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -import { SmartContract, State, state, Bool, Field, Provable, method, PublicKey, } from 'o1js'; +import { SmartContract, State, state, Field, method, PublicKey, } from 'o1js'; import { Manager } from './Manager.js'; export class ValidatorManager extends SmartContract { constructor() { super(...arguments); - this.validator1X = State(); - this.validator1Y = State(); - this.validator2X = State(); - this.validator2Y = State(); - this.validator3X = State(); - this.validator3Y = State(); + this.validator1 = State(); + this.validator2 = State(); + this.validator3 = State(); this.manager = State(); } - // @state(Field) validator4Y = State(); async deploy(args) { await super.deploy(args); - this.validator1X.set(args._val1X); - this.validator1Y.set(args._val1Y); - this.validator2X.set(args._val2X); - this.validator2Y.set(args._val2Y); - this.validator3X.set(args._val3X); - this.validator3Y.set(args._val3Y); + this.validator1.set(args._validator1); + this.validator2.set(args._validator2); + this.validator3.set(args._validator3); this.manager.set(args._manager); } - isValidator(xKey, yValue) { - return this.getValidatorIndex(xKey, yValue).greaterThan(Field(0)); + isValidator(p) { + return this.getValidatorIndex(p).greaterThan(Field(0)); } - getValidatorIndex(xKey, yValue) { - if (this.compareValidators(xKey, yValue, this.validator1X.getAndRequireEquals(), this.validator1Y.getAndRequireEquals()).toBoolean()) + getValidatorIndex(p) { + if (this.compareValidators(p, this.validator1.getAndRequireEquals())) return Field.from(1); - if (this.compareValidators(xKey, yValue, this.validator2X.getAndRequireEquals(), this.validator2Y.getAndRequireEquals()).toBoolean()) + if (this.compareValidators(p, this.validator2.getAndRequireEquals())) return Field.from(2); - if (this.compareValidators(xKey, yValue, this.validator3X.getAndRequireEquals(), this.validator3Y.getAndRequireEquals()).toBoolean()) + if (this.compareValidators(p, this.validator3.getAndRequireEquals())) return Field.from(3); - // if (this.compareValidators(xKey, yValue, this.validator4X.getAndRequireEquals(), this.validator4Y.getAndRequireEquals()).toBoolean()) return Field.from(4); return Field.from(0); } - compareValidators(x1, y1, x2, y2) { - Provable.log(`Comparing ${x1.toString()} and ${x2.toString()} + ${y1.toString()} and ${y2.toString()}`, Bool(x1.equals(x2) && y1.equals(y2))); - return Bool(x1.equals(x2) && y1.equals(y2)); + compareValidators(p1, p2) { + return p1.equals(p2); } - async changeValidator(xKey1, yKey1, xKey2, yKey2, xKey3, yKey3) { + async changeValidator(validator1, validator2, validator3) { const managerZkapp = new Manager(this.manager.getAndRequireEquals()); managerZkapp.isAdmin(this.sender.getAndRequireSignature()); - // Change the manager - this.validator1X.set(xKey1); - this.validator1Y.set(yKey1); - this.validator2X.set(xKey2); - this.validator2Y.set(yKey2); - this.validator3X.set(xKey3); - this.validator3Y.set(yKey3); + this.validator1.set(validator1); + this.validator2.set(validator2); + this.validator3.set(validator3); } } __decorate([ - state(Field), - __metadata("design:type", Object) -], ValidatorManager.prototype, "validator1X", void 0); -__decorate([ - state(Field), - __metadata("design:type", Object) -], ValidatorManager.prototype, "validator1Y", void 0); -__decorate([ - state(Field), - __metadata("design:type", Object) -], ValidatorManager.prototype, "validator2X", void 0); -__decorate([ - state(Field), + state(PublicKey), __metadata("design:type", Object) -], ValidatorManager.prototype, "validator2Y", void 0); +], ValidatorManager.prototype, "validator1", void 0); __decorate([ - state(Field), + state(PublicKey), __metadata("design:type", Object) -], ValidatorManager.prototype, "validator3X", void 0); +], ValidatorManager.prototype, "validator2", void 0); __decorate([ - state(Field), + state(PublicKey), __metadata("design:type", Object) -], ValidatorManager.prototype, "validator3Y", void 0); +], ValidatorManager.prototype, "validator3", void 0); __decorate([ state(PublicKey), __metadata("design:type", Object) @@ -91,12 +66,9 @@ __decorate([ __decorate([ method, __metadata("design:type", Function), - __metadata("design:paramtypes", [Field, - Field, - Field, - Field, - Field, - Field]), + __metadata("design:paramtypes", [PublicKey, + PublicKey, + PublicKey]), __metadata("design:returntype", Promise) ], ValidatorManager.prototype, "changeValidator", null); //# sourceMappingURL=ValidatorManager.js.map \ No newline at end of file diff --git a/build/src/ValidatorManager.js.map b/build/src/ValidatorManager.js.map index 33fb3ed..d162a63 100644 --- a/build/src/ValidatorManager.js.map +++ b/build/src/ValidatorManager.js.map @@ -1 +1 @@ -{"version":3,"file":"ValidatorManager.js","sourceRoot":"","sources":["../../src/ValidatorManager.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,aAAa,EACb,KAAK,EACL,KAAK,EACL,IAAI,EAEJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,SAAS,GACV,MAAM,MAAM,CAAA;AAIb,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAAnD;;QACgB,gBAAW,GAAG,KAAK,EAAS,CAAC;QAC7B,gBAAW,GAAG,KAAK,EAAS,CAAC;QAC7B,gBAAW,GAAG,KAAK,EAAS,CAAC;QAC7B,gBAAW,GAAG,KAAK,EAAS,CAAC;QAC7B,gBAAW,GAAG,KAAK,EAAS,CAAC;QAC7B,gBAAW,GAAG,KAAK,EAAS,CAAC;QACzB,YAAO,GAAG,KAAK,EAAa,CAAC;IA0DjD,CAAC;IAzDC,8CAA8C;IAE9C,KAAK,CAAC,MAAM,CAAC,IAQZ;QACC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACxB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,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DAA8B;AAuCjC;IAAb,MAAM;;qCACE,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;;uDAWb"} \ No newline at end of file +{"version":3,"file":"ValidatorManager.js","sourceRoot":"","sources":["../../src/ValidatorManager.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,aAAa,EACb,KAAK,EACL,KAAK,EAGL,KAAK,EAEL,MAAM,EACN,SAAS,GACV,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAAnD;;QACoB,eAAU,GAAG,KAAK,EAAa,CAAC;QAChC,eAAU,GAAG,KAAK,EAAa,CAAC;QAChC,eAAU,GAAG,KAAK,EAAa,CAAC;QAChC,YAAO,GAAG,KAAK,EAAa,CAAC;IA0CjD,CAAC;IAxCC,KAAK,CAAC,MAAM,CAAC,IAKZ;QACC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACxB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAEM,WAAW,CAAC,CAAY;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IAEM,iBAAiB,CAAC,CAAY;QACnC,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC;YAAE,OAAO,KAAK,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_deploy_all.js b/build/src/deploy/000_deploy_all.js index fddec5a..2838575 100644 --- a/build/src/deploy/000_deploy_all.js +++ b/build/src/deploy/000_deploy_all.js @@ -13,8 +13,8 @@ * Run with node: `$ node build/src/interact.js `. */ import fs from 'fs/promises'; -import { Mina, PrivateKey, AccountUpdate, UInt64, UInt8, Bool, Field } from 'o1js'; -import { FungibleToken, FungibleTokenAdmin, Bridge, Manager, ValidatorManager, Secp256k1 } from '../index.js'; +import { Mina, PrivateKey, AccountUpdate, UInt64, UInt8, Bool } from 'o1js'; +import { FungibleToken, FungibleTokenAdmin, Bridge, Manager, ValidatorManager } from '../index.js'; // check command line arg let deployAlias = process.argv[2]; if (!deployAlias) @@ -33,6 +33,9 @@ let adminContractKey = PrivateKey.random(); let bridgeContractKey = PrivateKey.random(); let managerKey = PrivateKey.random(); let validatorManagerKey = PrivateKey.random(); +const validator1Key = PrivateKey.random(); +const validator2Key = PrivateKey.random(); +const validator3Key = PrivateKey.random(); // set up Mina instance and contract we interact with const MINAURL = 'https://proxy.devnet.minaexplorer.com/graphql'; const ARCHIVEURL = 'https://api.minascan.io/archive/devnet/v1/graphql/'; @@ -59,6 +62,9 @@ let adminContractAddress = adminContractKey.toPublicKey(); let bridgeAddress = bridgeContractKey.toPublicKey(); let managerAddress = managerKey.toPublicKey(); let validatorManagerAddress = validatorManagerKey.toPublicKey(); +const validator1Address = validator1Key.toPublicKey(); +const validator2Address = validator2Key.toPublicKey(); +const validator3Address = validator3Key.toPublicKey(); const token = new FungibleToken(tokenAddress); const adminContract = new FungibleTokenAdmin(adminContractAddress); const bridgeContract = new Bridge(bridgeAddress); @@ -67,15 +73,6 @@ const validatorManagerContract = new ValidatorManager(validatorManagerAddress); const symbol = 'WETH'; const src = "https://github.com/MinaFoundation/mina-fungible-token/blob/main/FungibleToken.ts"; const supply = UInt64.from(21000000000000000); -let validatorSeed1 = "123456789012345678901234567890123456787"; -let validatorSeed2 = "123456789012345678901234567890123456788"; -let validatorSeed3 = "123456789012345678901234567890123456789"; -const validatorPrivateKeyGen1 = Secp256k1.Scalar.from(BigInt(validatorSeed1)); -const validatorPublicKey1 = Secp256k1.generator.scale(validatorPrivateKeyGen1); -const validatorPrivateKeyGen2 = Secp256k1.Scalar.from(BigInt(validatorSeed2)); -const validatorPublicKey2 = Secp256k1.generator.scale(validatorPrivateKeyGen2); -const validatorPrivateKeyGen3 = Secp256k1.Scalar.from(BigInt(validatorSeed3)); -const validatorPublicKey3 = Secp256k1.generator.scale(validatorPrivateKeyGen3); let sentTx; // compile the contract to create prover keys // await fetchAccount({publicKey: feepayerAddress}); @@ -95,12 +92,9 @@ try { _minter: feepayerAddress, }); await validatorManagerContract.deploy({ - _val1X: Field.from(validatorPublicKey1.x.toBigInt().toString()), - _val1Y: Field.from(validatorPublicKey1.y.toBigInt().toString()), - _val2X: Field.from(validatorPublicKey2.x.toBigInt().toString()), - _val2Y: Field.from(validatorPublicKey2.y.toBigInt().toString()), - _val3X: Field.from(validatorPublicKey3.x.toBigInt().toString()), - _val3Y: Field.from(validatorPublicKey3.y.toBigInt().toString()), + _validator1: validator1Address, + _validator2: validator2Address, + _validator3: validator3Address, _manager: managerAddress, }); await bridgeContract.deploy({ @@ -128,7 +122,10 @@ const keysToSave = [ { name: 'adminContract', privateKey: adminContractKey, publicKey: adminContractAddress }, { name: 'bridgeContract', privateKey: bridgeContractKey, publicKey: bridgeAddress }, { name: 'managerContract', privateKey: managerKey, publicKey: managerAddress }, - { name: 'validatorManagerContract', privateKey: validatorManagerKey, publicKey: validatorManagerAddress } + { name: 'validatorManagerContract', privateKey: validatorManagerKey, publicKey: validatorManagerAddress }, + { name: 'validator_1', privateKey: validator1Key, publicKey: validator1Address }, + { name: 'validator_2', privateKey: validator2Key, publicKey: validator2Address }, + { name: 'validator_3', privateKey: validator3Key, publicKey: validator3Address }, ]; const allKeys = {}; for (const key of keysToSave) { @@ -137,22 +134,7 @@ for (const key of keysToSave) { publicKey: key.publicKey.toBase58() }; } -allKeys['validator_1'] = { - seed: validatorSeed1 -}; -allKeys['validator_2'] = { - seed: validatorSeed2 -}; -allKeys['validator_3'] = { - seed: validatorSeed3 -}; console.log("🚀 ~ allKeys:", allKeys); -// const keysDir = path.join('..', '..', 'keys'); -// const fileName = path.join(keysDir, `${project_alias}_all_keys.json`); -// // Create the keys directory if it doesn't exist -// await fs.mkdir(keysDir, { recursive: true }); -// await fs.writeFile(fileName, JSON.stringify(allKeys, null, 2)); -// console.log(`Saved all keys to ${fileName}`); function getTxnUrl(graphQlUrl, txnHash) { const txnBroadcastServiceName = new URL(graphQlUrl).hostname .split('.') diff --git a/build/src/deploy/000_deploy_all.js.map b/build/src/deploy/000_deploy_all.js.map index 816a61b..db82d39 100644 --- a/build/src/deploy/000_deploy_all.js.map +++ b/build/src/deploy/000_deploy_all.js.map @@ -1 +1 @@ -{"version":3,"file":"000_deploy_all.js","sourceRoot":"","sources":["../../../src/deploy/000_deploy_all.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAA2B,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE9G,yBAAyB;AAEzB,IAAI,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClC,IAAI,CAAC,WAAW;IACd,MAAM,KAAK,CAAC;;;;CAIb,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,CAAC;AAe3C,IAAI,UAAU,GAAW,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9E,IAAI,MAAM,GAAG,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O,EAAE,CAAC;AACxC,CAAC"} \ No newline at end of file diff --git a/build/src/deploy/006_unlock_token.js b/build/src/deploy/006_unlock_token.js index 3feb3dc..ac58610 100644 --- a/build/src/deploy/006_unlock_token.js +++ b/build/src/deploy/006_unlock_token.js @@ -13,9 +13,8 @@ * Run with node: `$ node build/src/interact.js `. */ import fs from 'fs/promises'; -import { Mina, PrivateKey, AccountUpdate, fetchAccount, PublicKey, UInt64, Bool } from 'o1js'; -import { FungibleToken, FungibleTokenAdmin, Bridge, Secp256k1, ValidatorManager, Manager } from '../index.js'; -import { Bytes256, Ecdsa } from '../ecdsa/ecdsa.js'; +import { Mina, PrivateKey, AccountUpdate, fetchAccount, PublicKey, UInt64, Bool, Signature } from 'o1js'; +import { FungibleToken, FungibleTokenAdmin, Bridge, ValidatorManager, Manager } from '../index.js'; // check command line arg let deployAlias = process.argv[2]; if (!deployAlias) @@ -31,28 +30,37 @@ let feepayerKeysBase58 = JSON.parse(await fs.readFile(config.feepayerKeyPath, 'u let feepayerKey = PrivateKey.fromBase58(feepayerKeysBase58.privateKey); const allConfig = { token: { - privateKey: 'EKEEF6VqgxHGM1AnGCsEJkry7KUM3PfMhESCMDyaX81Xh2bSgKWW', - publicKey: 'B62qkEXoCDTeABfvpXmizZnah8Xtsy6LsUkMC4wQ1dBQYJapge5DJQY' + privateKey: 'EKFJCJnfuv85kSqrNyqMxhCJzCqKYrJ9Gd6Q7Laakvh6DcoAA8D4', + publicKey: 'B62qkuPGhLfrD12buqho48hSnc3DMGQ1d4ugzNjtYuRmSi5vvAjoZRz' }, adminContract: { - privateKey: 'EKFSjHF3PDsSBMaRD8eg95hgL96mehfLSNXMWS2ZxnRNTWBpvp86', - publicKey: 'B62qqGHGFcvPvRNNcSfciPUhq5w4Q8QSJGZn8PEMeu7sBPq8XnmXY4U' + privateKey: 'EKFWVTP5cmdkeu3n3TEHo5jEToo2YVLiJCWR4zjbpavAJV4eSpUt', + publicKey: 'B62qqY8QRCbTbUM2Va3Lzn91EZKWWFaobX5KhFmpbve4wzvgo7ZER9A' }, bridgeContract: { - privateKey: 'EKEdWnS3pfLTWeBBhaNGWgGCQagLkXAUXcmrLh3K1GYqNLSMFTBS', - publicKey: 'B62qkz1P3ftenFunfUGsoQGb3ZeftKmYkYQbfY4vC3avSJJxJ4uQHr2' + privateKey: 'EKFVE4fiRtBgdkKgffRzcNHZ6GJmkg95mWEDatmJ3ZueGgZg5K4W', + publicKey: 'B62qqKFZav5StzHmRkaU21Mw34CgGu5fWCsdGcCuxdgjZb3MSrxo67Q' }, managerContract: { - privateKey: 'EKDxPsi367kKBD8QLYZK2LfmXHt8oqxqwKY1pSnQ3wrQFRcogfhE', - publicKey: 'B62qjZjqY47JEyeYfaAjRHHGEMV1deRLj4J2o4yB8JPoYa6QwRNs3sc' + privateKey: 'EKEmiXywqnKC8vWXko8ktKnGbYbQqmCHfrZ7YRbKRZEr1PREcDNN', + publicKey: 'B62qpTBL7K2NEYfiW5jLr4p8iY3x1kccyMETFi7ZUwFor5Viw337ivd' }, validatorManagerContract: { - privateKey: 'EKE4ZVgaYhgsSBapK89ktUgzE5MiZZkXpVPyePqmoV4c23e5x4nv', - publicKey: 'B62qjZmg2hbtJcjQ8k2UaFa3ZTHiJ1yKUVSuQrmbWoHst3Hse5oaiSM' + privateKey: 'EKEfwksv72JHarTSZAXgeSwcZGejvRkcdVmPQ7mujtczv2gJhQU6', + publicKey: 'B62qnFAsrYfqgRk8MD8F5Lbpi6RdqkEb7wqJjYhQk3NbC2mQmjcFGJ1' }, - validator_1: { seed: '123456789012345678901234567890123456787' }, - validator_2: { seed: '123456789012345678901234567890123456788' }, - validator_3: { seed: '123456789012345678901234567890123456789' } + validator_1: { + privateKey: 'EKE8MzLKBQQn3v53v6JSCXHRPvrTwAB6xytnxYfpATgYnX17bMeM', + publicKey: 'B62qnatDbNraYYPAnUYW1rGpS5tzXsGzLvyPebafNseYgNrHF83eu7d' + }, + validator_2: { + privateKey: 'EKF3PE1286RVzZNgieYeDw96LrMKc6V2szhvV2zyj2Z9qLwzc1SG', + publicKey: 'B62qroF6gTiaDNBqFETV2wPWmdVxufxaQHr3gKSGqh9U4tXVYjJZsVc' + }, + validator_3: { + privateKey: 'EKEqLGiiuaZwAV5XZeWGWBsQUmBCXAWR5zzq2vZtyCXou7ZYwryi', + publicKey: 'B62qjM9WyCn9BK2jyv6KkuLeXqiWsvaFPNtkNt9snt7U1TKxcZq9q7P' + } }; let tokenKey = PrivateKey.fromBase58(allConfig["token"].privateKey); let adminContractKey = PrivateKey.fromBase58(allConfig["adminContract"].privateKey); @@ -87,21 +95,24 @@ let managerContract = new Manager(managerAddress); let validatorManagerContract = new ValidatorManager(validatorManagerAddress); await fetchAccount({ publicKey: managerAddress }); await fetchAccount({ publicKey: validatorManagerAddress }); -const x1 = await validatorManagerContract.validator1X.get(); -console.log("🚀 ~ x1:", x1); -const admin = await managerContract.admin.get(); -console.log("🚀 ~ admin:", admin); const symbol = 'WETH'; const src = "https://github.com/MinaFoundation/mina-fungible-token/blob/main/FungibleToken.ts"; const supply = UInt64.from(21000000000000); -const seed1 = allConfig['validator_1'].seed; -let privateKey = Secp256k1.Scalar.from(seed1); -let publicKey = Secp256k1.generator.scale(privateKey); +const validator1Privkey = PrivateKey.fromBase58(allConfig.validator_1.privateKey); +const validator2Privkey = PrivateKey.fromBase58(allConfig.validator_2.privateKey); +const validator3Privkey = PrivateKey.fromBase58(allConfig.validator_3.privateKey); +const validator1 = validator1Privkey.toPublicKey(); +const validator2 = validator2Privkey.toPublicKey(); +const validator3 = validator3Privkey.toPublicKey(); let amount = UInt64.from(2000000000000); // let receiver = PublicKey.fromBase58("B62qmHMUwiyNfv81NNTumW7Hv8SfRAGLXceGK3ZpyzXgmg2FLqmVhmA"); let receiver = PublicKey.fromBase58("B62qjWwgHupW7k7fcTbb2Kszp4RPYBWYdL4KMmoqfkMH3iRN2FN8u5n"); -let msg = Bytes256.fromString(`unlock receiver = ${receiver.toFields} amount = ${amount.toFields} tokenAddr = ${tokenAddress.toFields}`); -let signature = Ecdsa.sign(msg.toBytes(), privateKey.toBigInt()); +const msg = [ + ...receiver.toFields(), + ...amount.toFields(), + ...tokenAddress.toFields(), +]; +const signature = await Signature.create(validator1Privkey, msg); let sentTx; // compile the contract to create prover keys await fetchAccount({ publicKey: feepayerAddress }); @@ -110,7 +121,7 @@ try { console.log('build transaction and create proof...'); let tx = await Mina.transaction({ sender: feepayerAddress, fee }, async () => { await AccountUpdate.fundNewAccount(feepayerAddress, 1); - await bridgeContract.unlock(amount, receiver, UInt64.from(1), tokenAddress, Bool(true), signature, publicKey, Bool(false), signature, publicKey, Bool(false), signature, publicKey); + await bridgeContract.unlock(amount, receiver, UInt64.from(1), tokenAddress, Bool(true), validator1, signature, Bool(false), validator2, signature, Bool(false), validator3, signature); }); await tx.prove(); console.log('send transaction...'); diff --git a/build/src/deploy/006_unlock_token.js.map b/build/src/deploy/006_unlock_token.js.map index f86d57d..a6dbf27 100644 --- a/build/src/deploy/006_unlock_token.js.map +++ b/build/src/deploy/006_unlock_token.js.map @@ -1 +1 @@ -{"version":3,"file":"006_unlock_token.js","sourceRoot":"","sources":["../../../src/deploy/006_unlock_token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAS,IAAI,EAAS,MAAM,MAAM,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,yBAAyB;AAEzB,IAAI,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClC,IAAI,CAAC,WAAW;IACd,MAAM,KAAK,CAA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AC;CACjE;AAAC,OAAO,GAAG,EAAE;IACZ,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAClB;AACD,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAC3D,MAAM,MAAM,EAAE,IAAI,EAAE,CAAC;AAErB,SAAS,SAAS,CAAC,UAAkB,EAAE,OAA2B;IAChE,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,QAAQ;SACzD,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,QAAQ;SAC7C,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtE,IAAI,uBAAuB,IAAI,WAAW,EAAE;QAC1C,OAAO,uBAAuB,WAAW,OAAO,OAAO,aAAa,CAAC;KACtE;IACD,OAAO,qBAAqB,OAAO,EAAE,CAAC;AACxC,CAAC"} \ No newline at end of file diff --git a/src/Bridge.test.ts b/src/Bridge.test.ts index f2f96bc..8514873 100644 --- a/src/Bridge.test.ts +++ b/src/Bridge.test.ts @@ -1,4 +1,4 @@ -import { Account, AccountUpdate, Bool, EcdsaSignature, EcdsaSignatureV2, Encoding, Experimental, Field, Int64, MerkleMap, Mina, PrivateKey, Provable, PublicKey, UInt64, UInt8, fetchAccount } from 'o1js' +import { Account, AccountUpdate, Bool, EcdsaSignature, EcdsaSignatureV2, Encoding, Experimental, Field, Int64, MerkleMap, Mina, PrivateKey, Provable, PublicKey, Signature, UInt64, UInt8, fetchAccount } from 'o1js' import { Bridge } from './Bridge' import { FungibleToken, FungibleTokenAdmin } from 'mina-fungible-token'; import { Bytes256, ecdsa, Ecdsa, keccakAndEcdsa, Secp256k1 } from './ecdsa/ecdsa'; @@ -18,30 +18,18 @@ describe("Bridge", () => { const normalUserPrivkey = Local.testAccounts[2].key const normalUserPubkey = Local.testAccounts[2] - const validatorPrivateKey1 = Secp256k1.Scalar.random(); - const validatorPublicKey1 = Secp256k1.generator.scale(validatorPrivateKey1); + const validator1Privkey = Local.testAccounts[3].key + const validator1Pubkey = Local.testAccounts[3] - const validatorPrivateKey2 = Secp256k1.Scalar.random(); - const validatorPublicKey2 = Secp256k1.generator.scale(validatorPrivateKey2); + const validator2Privkey = Local.testAccounts[4].key + const validator2Pubkey = Local.testAccounts[4] - const validatorPrivateKey3 = Secp256k1.Scalar.random(); - const validatorPublicKey3 = Secp256k1.generator.scale(validatorPrivateKey3); + const validator3Privkey = Local.testAccounts[5].key + const validator3Pubkey = Local.testAccounts[5] - const validatorPrivateKeyGen = Secp256k1.Scalar.from(BigInt('123456789012345678901234567890123456789')); - const validatorPublicKeyGen = Secp256k1.generator.scale(validatorPrivateKeyGen); - console.log("🚀 ~ describe ~ validatorPublicKeyGen:", validatorPublicKeyGen) - console.log("🚀 ~ describe ~ validatorPublicKeyGen x :", validatorPublicKeyGen.x.toBigInt().toString()); - console.log("🚀 ~ describe ~ validatorPublicKeyGen y :", validatorPublicKeyGen.y.toBigInt().toString()); - const x1 = Field.from(validatorPublicKey1.x.toBigInt().toString()); - const y1 = Field.from(validatorPublicKey1.y.toBigInt().toString()); - let x2 = Field.from(validatorPublicKey2.x.toBigInt().toString()); - let y2 = Field.from(validatorPublicKey2.y.toBigInt().toString()); - - let x3 = Field.from(validatorPublicKey3.x.toBigInt().toString()); - let y3 = Field.from(validatorPublicKey3.y.toBigInt().toString()); const adminContractPrivkey = PrivateKey.random() const adminContractPubkey = adminContractPrivkey.toPublicKey() @@ -126,12 +114,9 @@ describe("Bridge", () => { let validatorManagerTx = await Mina.transaction(userPubkey, async () => { AccountUpdate.fundNewAccount(userPubkey, 1) await validatorZkapp.deploy({ - _val1X: x1, - _val1Y: y1, - _val2X: x2, - _val2Y: y2, - _val3X: x3, - _val3Y: y3, + _validator1: validator1Pubkey, + _validator2: validator2Pubkey, + _validator3: validator3Pubkey, _manager: managerPubkey, }) }) @@ -248,28 +233,32 @@ describe("Bridge", () => { // console.log("publicKey_1:", publicKey_1); let amount = UInt64.from(10); + const msg = [ + ...normalUserPubkey.toFields(), + ...amount.toFields(), + ...tokenPubkey.toFields(), + ] + - let msg = Bytes256.fromString(`unlock receiver = ${normalUserPubkey.toFields} amount = ${amount.toFields} tokenAddr = ${tokenPubkey.toFields}`); - let signature = Ecdsa.sign(msg.toBytes(), validatorPrivateKey1.toBigInt()); - let signature1 = Ecdsa.sign(msg.toBytes(), privateKey_1.toBigInt()); + let signature = Signature.create(userPrivkey, msg); + let signature1 = Signature.create(normalUserPrivkey, msg);; let unlockTx = await Mina.transaction(userPubkey, async () => { - // AccountUpdate.fundNewAccount(userPubkey, 1); await bridgeZkapp.unlock( amount, normalUserPubkey, UInt64.from(1), tokenPubkey, Bool(true), + userPubkey, signature, - validatorPublicKey1, Bool(false), + userPubkey, signature, - validatorPublicKey1, Bool(false), + userPubkey, signature, - validatorPublicKey1, ); }) unlockTx.sign([userPrivkey, bridgePrivkey]) @@ -290,6 +279,20 @@ describe("Bridge", () => { const afterLockBalance = await token.getBalanceOf(normalUserPubkey); console.log("after lock balance:", afterLockBalance.toString()); + // const msg: Field[] = [Field.from(1), Field.from(2), Field.from(3)]; + // const msg1: Field[] = [Field.from(1), Field.from(2), Field.from(4)]; + // const sig = Signature.create(normalUserPrivkey, msg); + + + + // let lockTx = await Mina.transaction(userPubkey, async () => { + // await bridgeZkapp.verifyMsg(normalUserPubkey, msg1, sig); + // }) + // lockTx.sign([userPrivkey]) + // await lockTx.prove() + // await lockTx.send() + + // const check = await validatorZkapp.isValidator(publicKey_1) // console.log("��� ~ it ~ check:", check.toString()); }) diff --git a/src/Bridge.ts b/src/Bridge.ts index 74dfe28..a563272 100644 --- a/src/Bridge.ts +++ b/src/Bridge.ts @@ -6,25 +6,15 @@ import { method, state, Struct, - CircuitString, Bool, DeployArgs, - Permissions, Provable, Field, - ZkProgram, - Crypto, - createEcdsaV2, - createForeignCurveV2, - Poseidon, MerkleMap, - MerkleMapWitness, - fetchAccount + Signature } from 'o1js' import { FungibleToken } from "mina-fungible-token" - -import { Secp256k1, Ecdsa, keccakAndEcdsa, ecdsa, Bytes32, Bytes256 } from './ecdsa/ecdsa.js'; import { ValidatorManager } from './ValidatorManager.js'; import { Manager } from './Manager.js'; @@ -33,12 +23,12 @@ class UnlockEvent extends Struct({ tokenAddress: PublicKey, amount: UInt64, id: UInt64, -}){ +}) { constructor( - receiver: PublicKey, - tokenAddress: PublicKey, - amount: UInt64, - id: UInt64, + receiver: PublicKey, + tokenAddress: PublicKey, + amount: UInt64, + id: UInt64, ) { super({ receiver, tokenAddress, amount, id }); } @@ -49,7 +39,7 @@ class LockEvent extends Struct({ receipt: Field, amount: UInt64, tokenAddress: PublicKey -}){ +}) { constructor(locker: PublicKey, receipt: Field, amount: UInt64, tokenAddress: PublicKey) { super({ locker, receipt, amount, tokenAddress }); } @@ -62,9 +52,9 @@ export class Bridge extends SmartContract { @state(PublicKey) validatorManager = State(); @state(PublicKey) manager = State(); - events = {"Unlock": UnlockEvent, "Lock": LockEvent}; + events = { "Unlock": UnlockEvent, "Lock": LockEvent }; - async deploy(args: DeployArgs & { + async deploy(args: DeployArgs & { minAmount: UInt64, maxAmount: UInt64, threshold: UInt64, @@ -82,7 +72,7 @@ export class Bridge extends SmartContract { @method async setAmountLimits(newMinAmount: UInt64, newMaxAmount: UInt64) { // Ensure the caller is the manager - + const managerZkapp = new Manager(this.manager.getAndRequireEquals()); managerZkapp.isAdmin(this.sender.getAndRequireSignature()); // Set the new minimum and maximum amounts @@ -112,7 +102,7 @@ export class Bridge extends SmartContract { // Check if the amount is within the allowed range const minAmount = this.minAmount.getAndRequireEquals(); const maxAmount = this.maxAmount.getAndRequireEquals(); - + amount.assertGreaterThanOrEqual(minAmount, "Amount is less than minimum allowed"); amount.assertLessThanOrEqual(maxAmount, "Amount exceeds maximum allowed"); const token = new FungibleToken(tokenAddr); @@ -127,105 +117,88 @@ export class Bridge extends SmartContract { id: UInt64, tokenAddr: PublicKey, useSig1: Bool, - signature_1: Ecdsa, - validator_1: Secp256k1, + validator1: PublicKey, + sig1: Signature, useSig2: Bool, - signature_2: Ecdsa, - validator_2: Secp256k1, + validator2: PublicKey, + sig2: Signature, useSig3: Bool, - signature_3: Ecdsa, - validator_3: Secp256k1, + validator3: PublicKey, + sig3: Signature, ) { const managerZkapp = new Manager(this.manager.getAndRequireEquals()); managerZkapp.isAdmin(this.sender.getAndRequireSignature()); - let msg = Bytes256.fromString(`unlock receiver = ${receiver.toFields} amount = ${amount.toFields} tokenAddr = ${tokenAddr.toFields}`); + const msg = [ + ...receiver.toFields(), + ...amount.toFields(), + ...tokenAddr.toFields(), + ] this.validateValidator( useSig1, - validator_1, + validator1, useSig2, - validator_2, + validator2, useSig3, - validator_3, + validator3, ); - this.validateSig(msg, signature_1, validator_1, useSig1); - this.validateSig(msg, signature_2, validator_2, useSig2); - this.validateSig(msg, signature_3, validator_3, useSig3); - + this.validateSig(msg, sig1, validator1, useSig1); + this.validateSig(msg, sig2, validator2, useSig2); + this.validateSig(msg, sig3, validator3, useSig3); const token = new FungibleToken(tokenAddr) await token.mint(receiver, amount) this.emitEvent("Unlock", new UnlockEvent(receiver, tokenAddr, amount, id)); } - public isValidator(validator: Secp256k1, useSig: Bool): Bool { - const validatorManager = new ValidatorManager(this.validatorManager.getAndRequireEquals()); - let isValid = Bool(false); - Provable.asProver(() => { - const x = Field.from(validator.x.toBigInt()); - const y = Field.from(validator.y.toBigInt()); - isValid = useSig.toBoolean() ? validatorManager.isValidator(x, y): Bool(false); - Provable.log("isValid", isValid); - }) - return isValid; - } - public validateValidator( + public async validateValidator( useSig1: Bool, - validator_1: Secp256k1, + validator1: PublicKey, useSig2: Bool, - validator_2: Secp256k1, + validator2: PublicKey, useSig3: Bool, - validator_3: Secp256k1, - ) { + validator3: PublicKey, + ) { + let count = UInt64.from(0); + const zero = Field.from(0); + const falseB = Bool(false); + const trueB = Bool(true); + const validatorManager = new ValidatorManager(this.validatorManager.getAndRequireEquals()); + const validateIndex = async (validator: PublicKey, useSig: Bool) => { + const index = await validatorManager.getValidatorIndex(validator); + const isGreaterThanZero = index.greaterThan(zero); + let isOk = Provable.if(useSig, Provable.if(isGreaterThanZero, trueB, falseB), trueB); + isOk.assertTrue("Public key not found in validators"); + }; + + const notDupValidator12 = Provable.if(useSig1.and(useSig2), Provable.if(validator1.equals(validator2), falseB, trueB), trueB); + const notDupValidator13 = Provable.if(useSig1.and(useSig3), Provable.if(validator1.equals(validator3), falseB, trueB),trueB); + const notDupValidator23 = Provable.if(useSig2.and(useSig3), Provable.if(validator2.equals(validator3), falseB, trueB), trueB); + + const isDuplicate = Provable.if( + notDupValidator12.and(notDupValidator13).and(notDupValidator23), + falseB, + trueB, + ); + + isDuplicate.assertFalse("Duplicate validator keys"); + + count = Provable.if(useSig1, count.add(1), count); + count = Provable.if(useSig2, count.add(1), count); + count = Provable.if(useSig3, count.add(1), count); + count.assertGreaterThanOrEqual(this.threshold.getAndRequireEquals(), "Not reached threshold"); - Provable.asProver(async () => { - const map = new MerkleMap(); - - const checkValidator = (useSig: Bool, validator: Secp256k1) => { - if (useSig.toBoolean()) { - const x = Field.from(validator.x.toBigInt()); - const y = Field.from(validator.y.toBigInt()); - let yMap = map.get(x); - yMap.assertNotEquals(y); - map.set(x, y); - } - }; - - checkValidator(useSig1, validator_1); - checkValidator(useSig2, validator_2); - checkValidator(useSig3, validator_3); - }) - - if (this.isValidator(validator_1, useSig1).toBoolean()) { - count = count.add(1); - } - if (this.isValidator(validator_2, useSig2).toBoolean()) { - count = count.add(1); - } - if (this.isValidator(validator_3, useSig3).toBoolean()) { - count = count.add(1); - } - Provable.log("count", count); - - count.assertGreaterThanOrEqual(this.threshold.getAndRequireEquals(), "Not enough validators"); } - public async validateSig(msg: Bytes256, signature: Ecdsa, validator: Secp256k1, useSig: Bool) { - let isValid = Bool(false); - Provable.asProver(async () => { - if (useSig.toBoolean()) { - isValid = await this.validateMsg(msg, signature, validator); - Provable.log("validateMsg isValid", isValid); - isValid.assertTrue("Invalid signature for validator"); - } - }) - + public async validateSig(msg: Field[], signature: Signature, validator: PublicKey, useSig: Bool) { + let isValidSig = signature.verify(validator, msg); + const isValid = Provable.if(useSig, isValidSig, Bool(true)); + isValid.assertTrue("Invalid signature"); } - public async validateMsg(message: Bytes32, signature: Ecdsa, publicKey: Secp256k1): Promise { - let proof = await signature.verifyV2(message, publicKey); - Provable.log("proof", proof); - return proof; + public async verifyMsg(publicKey: PublicKey, msg: Field[], sig: Signature) { + const isOk = await sig.verify(publicKey, msg); + Provable.log("isOk", isOk.toString()); } } \ No newline at end of file diff --git a/src/ValidatorManager.ts b/src/ValidatorManager.ts index 417c35f..dbe3c19 100644 --- a/src/ValidatorManager.ts +++ b/src/ValidatorManager.ts @@ -10,73 +10,52 @@ import { PublicKey, } from 'o1js' - -import { Secp256k1, Ecdsa, keccakAndEcdsa, ecdsa, Bytes32, Bytes256 } from './ecdsa/ecdsa.js'; import { Manager } from './Manager.js'; export class ValidatorManager extends SmartContract { - @state(Field) validator1X = State(); - @state(Field) validator1Y = State(); - @state(Field) validator2X = State(); - @state(Field) validator2Y = State(); - @state(Field) validator3X = State(); - @state(Field) validator3Y = State(); + @state(PublicKey) validator1 = State(); + @state(PublicKey) validator2 = State(); + @state(PublicKey) validator3 = State(); @state(PublicKey) manager = State(); - // @state(Field) validator4Y = State(); async deploy(args: DeployArgs & { - _val1X: Field, - _val1Y: Field, - _val2X: Field, - _val2Y: Field, - _val3X: Field, - _val3Y: Field, + _validator1: PublicKey, + _validator2: PublicKey, + _validator3: PublicKey, _manager: PublicKey, }) { await super.deploy(args) - this.validator1X.set(args._val1X); - this.validator1Y.set(args._val1Y); - this.validator2X.set(args._val2X); - this.validator2Y.set(args._val2Y); - this.validator3X.set(args._val3X); - this.validator3Y.set(args._val3Y); + this.validator1.set(args._validator1); + this.validator2.set(args._validator2); + this.validator3.set(args._validator3); this.manager.set(args._manager); } - public isValidator(xKey: Field, yValue: Field): Bool { - return this.getValidatorIndex(xKey, yValue).greaterThan(Field(0)); + public isValidator(p: PublicKey): Bool { + return this.getValidatorIndex(p).greaterThan(Field(0)); } - public getValidatorIndex(xKey: Field, yValue: Field): Field { - if (this.compareValidators(xKey, yValue, this.validator1X.getAndRequireEquals(), this.validator1Y.getAndRequireEquals()).toBoolean()) return Field.from(1); - if (this.compareValidators(xKey, yValue, this.validator2X.getAndRequireEquals(), this.validator2Y.getAndRequireEquals()).toBoolean()) return Field.from(2); - if (this.compareValidators(xKey, yValue, this.validator3X.getAndRequireEquals(), this.validator3Y.getAndRequireEquals()).toBoolean()) return Field.from(3); - // if (this.compareValidators(xKey, yValue, this.validator4X.getAndRequireEquals(), this.validator4Y.getAndRequireEquals()).toBoolean()) return Field.from(4); + public getValidatorIndex(p: PublicKey): Field { + if (this.compareValidators(p, this.validator1.getAndRequireEquals())) return Field.from(1); + if (this.compareValidators(p, this.validator2.getAndRequireEquals())) return Field.from(2); + if (this.compareValidators(p, this.validator3.getAndRequireEquals())) return Field.from(3); return Field.from(0); } - public compareValidators(x1: Field, y1: Field, x2: Field, y2: Field): Bool { - Provable.log(`Comparing ${x1.toString()} and ${x2.toString()} + ${y1.toString()} and ${y2.toString()}`, Bool(x1.equals(x2) && y1.equals(y2))); - return Bool(x1.equals(x2) && y1.equals(y2)); + public compareValidators(p1: PublicKey, p2: PublicKey): Bool { + return p1.equals(p2) } @method async changeValidator( - xKey1: Field, - yKey1: Field, - xKey2: Field, - yKey2: Field, - xKey3: Field, - yKey3: Field, + validator1: PublicKey, + validator2: PublicKey, + validator3: PublicKey, ) { const managerZkapp = new Manager(this.manager.getAndRequireEquals()); managerZkapp.isAdmin(this.sender.getAndRequireSignature()); - // Change the manager - this.validator1X.set(xKey1); - this.validator1Y.set(yKey1); - this.validator2X.set(xKey2); - this.validator2Y.set(yKey2); - this.validator3X.set(xKey3); - this.validator3Y.set(yKey3); + this.validator1.set(validator1); + this.validator2.set(validator2); + this.validator3.set(validator3); } } \ No newline at end of file diff --git a/src/deploy/000_deploy_all.ts b/src/deploy/000_deploy_all.ts index d73aad0..c913e29 100644 --- a/src/deploy/000_deploy_all.ts +++ b/src/deploy/000_deploy_all.ts @@ -57,6 +57,10 @@ let bridgeContractKey = PrivateKey.random(); let managerKey = PrivateKey.random(); let validatorManagerKey = PrivateKey.random(); +const validator1Key = PrivateKey.random(); +const validator2Key = PrivateKey.random(); +const validator3Key = PrivateKey.random(); + // set up Mina instance and contract we interact with const MINAURL = 'https://proxy.devnet.minaexplorer.com/graphql'; const ARCHIVEURL = 'https://api.minascan.io/archive/devnet/v1/graphql/'; @@ -87,6 +91,9 @@ let adminContractAddress = adminContractKey.toPublicKey(); let bridgeAddress = bridgeContractKey.toPublicKey(); let managerAddress = managerKey.toPublicKey(); let validatorManagerAddress = validatorManagerKey.toPublicKey(); +const validator1Address = validator1Key.toPublicKey(); +const validator2Address = validator2Key.toPublicKey(); +const validator3Address = validator3Key.toPublicKey(); const token = new FungibleToken(tokenAddress) const adminContract = new FungibleTokenAdmin(adminContractAddress) @@ -99,18 +106,7 @@ const symbol = 'WETH'; const src = "https://github.com/MinaFoundation/mina-fungible-token/blob/main/FungibleToken.ts"; const supply = UInt64.from(21_000_000_000_000_000) -let validatorSeed1 = "123456789012345678901234567890123456787"; -let validatorSeed2 = "123456789012345678901234567890123456788"; -let validatorSeed3 = "123456789012345678901234567890123456789"; - -const validatorPrivateKeyGen1 = Secp256k1.Scalar.from(BigInt(validatorSeed1)); -const validatorPublicKey1 = Secp256k1.generator.scale(validatorPrivateKeyGen1); -const validatorPrivateKeyGen2 = Secp256k1.Scalar.from(BigInt(validatorSeed2)); -const validatorPublicKey2 = Secp256k1.generator.scale(validatorPrivateKeyGen2); - -const validatorPrivateKeyGen3 = Secp256k1.Scalar.from(BigInt(validatorSeed3)); -const validatorPublicKey3 = Secp256k1.generator.scale(validatorPrivateKeyGen3); let sentTx; @@ -140,12 +136,9 @@ try { }) await validatorManagerContract.deploy({ - _val1X: Field.from(validatorPublicKey1.x.toBigInt().toString()), - _val1Y: Field.from(validatorPublicKey1.y.toBigInt().toString()), - _val2X: Field.from(validatorPublicKey2.x.toBigInt().toString()), - _val2Y: Field.from(validatorPublicKey2.y.toBigInt().toString()), - _val3X: Field.from(validatorPublicKey3.x.toBigInt().toString()), - _val3Y: Field.from(validatorPublicKey3.y.toBigInt().toString()), + _validator1: validator1Address, + _validator2: validator2Address, + _validator3: validator3Address, _manager: managerAddress, }); @@ -175,7 +168,10 @@ const keysToSave = [ { name: 'adminContract', privateKey: adminContractKey, publicKey: adminContractAddress }, { name: 'bridgeContract', privateKey: bridgeContractKey, publicKey: bridgeAddress }, { name: 'managerContract', privateKey: managerKey, publicKey: managerAddress }, - { name: 'validatorManagerContract', privateKey: validatorManagerKey, publicKey: validatorManagerAddress } + { name: 'validatorManagerContract', privateKey: validatorManagerKey, publicKey: validatorManagerAddress }, + { name: 'validator_1', privateKey: validator1Key, publicKey: validator1Address }, + { name: 'validator_2', privateKey: validator2Key, publicKey: validator2Address }, + { name: 'validator_3', privateKey: validator3Key, publicKey: validator3Address }, ]; const allKeys = {}; @@ -186,30 +182,8 @@ for (const key of keysToSave) { }; } -(allKeys as Record)['validator_1'] = { - seed: validatorSeed1 -}; - -(allKeys as Record)['validator_2'] = { - seed: validatorSeed2 -}; - -(allKeys as Record)['validator_3'] = { - seed: validatorSeed3 -}; - console.log("🚀 ~ allKeys:", allKeys); -// const keysDir = path.join('..', '..', 'keys'); -// const fileName = path.join(keysDir, `${project_alias}_all_keys.json`); - -// // Create the keys directory if it doesn't exist -// await fs.mkdir(keysDir, { recursive: true }); - - -// await fs.writeFile(fileName, JSON.stringify(allKeys, null, 2)); -// console.log(`Saved all keys to ${fileName}`); - function getTxnUrl(graphQlUrl: string, txnHash: string | undefined) { const txnBroadcastServiceName = new URL(graphQlUrl).hostname .split('.') diff --git a/src/deploy/006_unlock_token.ts b/src/deploy/006_unlock_token.ts index fa5947b..686d53f 100644 --- a/src/deploy/006_unlock_token.ts +++ b/src/deploy/006_unlock_token.ts @@ -13,7 +13,7 @@ * Run with node: `$ node build/src/interact.js `. */ import fs from 'fs/promises'; -import { Mina, PrivateKey, AccountUpdate, fetchAccount, PublicKey, UInt64, UInt8, Bool, Field } from 'o1js'; +import { Mina, PrivateKey, AccountUpdate, fetchAccount, PublicKey, UInt64, UInt8, Bool, Field, Signature } from 'o1js'; import { FungibleToken, FungibleTokenAdmin, Bridge, Secp256k1, ValidatorManager, Manager } from '../index.js'; import { Bytes256, Ecdsa } from '../ecdsa/ecdsa.js'; @@ -55,33 +55,40 @@ let feepayerKey = PrivateKey.fromBase58(feepayerKeysBase58.privateKey); const allConfig = { token: { - privateKey: 'EKEEF6VqgxHGM1AnGCsEJkry7KUM3PfMhESCMDyaX81Xh2bSgKWW', - publicKey: 'B62qkEXoCDTeABfvpXmizZnah8Xtsy6LsUkMC4wQ1dBQYJapge5DJQY' + privateKey: 'EKFJCJnfuv85kSqrNyqMxhCJzCqKYrJ9Gd6Q7Laakvh6DcoAA8D4', + publicKey: 'B62qkuPGhLfrD12buqho48hSnc3DMGQ1d4ugzNjtYuRmSi5vvAjoZRz' }, adminContract: { - privateKey: 'EKFSjHF3PDsSBMaRD8eg95hgL96mehfLSNXMWS2ZxnRNTWBpvp86', - publicKey: 'B62qqGHGFcvPvRNNcSfciPUhq5w4Q8QSJGZn8PEMeu7sBPq8XnmXY4U' + privateKey: 'EKFWVTP5cmdkeu3n3TEHo5jEToo2YVLiJCWR4zjbpavAJV4eSpUt', + publicKey: 'B62qqY8QRCbTbUM2Va3Lzn91EZKWWFaobX5KhFmpbve4wzvgo7ZER9A' }, bridgeContract: { - privateKey: 'EKEdWnS3pfLTWeBBhaNGWgGCQagLkXAUXcmrLh3K1GYqNLSMFTBS', - publicKey: 'B62qkz1P3ftenFunfUGsoQGb3ZeftKmYkYQbfY4vC3avSJJxJ4uQHr2' + privateKey: 'EKFVE4fiRtBgdkKgffRzcNHZ6GJmkg95mWEDatmJ3ZueGgZg5K4W', + publicKey: 'B62qqKFZav5StzHmRkaU21Mw34CgGu5fWCsdGcCuxdgjZb3MSrxo67Q' }, managerContract: { - privateKey: 'EKDxPsi367kKBD8QLYZK2LfmXHt8oqxqwKY1pSnQ3wrQFRcogfhE', - publicKey: 'B62qjZjqY47JEyeYfaAjRHHGEMV1deRLj4J2o4yB8JPoYa6QwRNs3sc' + privateKey: 'EKEmiXywqnKC8vWXko8ktKnGbYbQqmCHfrZ7YRbKRZEr1PREcDNN', + publicKey: 'B62qpTBL7K2NEYfiW5jLr4p8iY3x1kccyMETFi7ZUwFor5Viw337ivd' }, validatorManagerContract: { - privateKey: 'EKE4ZVgaYhgsSBapK89ktUgzE5MiZZkXpVPyePqmoV4c23e5x4nv', - publicKey: 'B62qjZmg2hbtJcjQ8k2UaFa3ZTHiJ1yKUVSuQrmbWoHst3Hse5oaiSM' + privateKey: 'EKEfwksv72JHarTSZAXgeSwcZGejvRkcdVmPQ7mujtczv2gJhQU6', + publicKey: 'B62qnFAsrYfqgRk8MD8F5Lbpi6RdqkEb7wqJjYhQk3NbC2mQmjcFGJ1' }, - validator_1: { seed: '123456789012345678901234567890123456787' }, - validator_2: { seed: '123456789012345678901234567890123456788' }, - validator_3: { seed: '123456789012345678901234567890123456789' } + validator_1: { + privateKey: 'EKE8MzLKBQQn3v53v6JSCXHRPvrTwAB6xytnxYfpATgYnX17bMeM', + publicKey: 'B62qnatDbNraYYPAnUYW1rGpS5tzXsGzLvyPebafNseYgNrHF83eu7d' + }, + validator_2: { + privateKey: 'EKF3PE1286RVzZNgieYeDw96LrMKc6V2szhvV2zyj2Z9qLwzc1SG', + publicKey: 'B62qroF6gTiaDNBqFETV2wPWmdVxufxaQHr3gKSGqh9U4tXVYjJZsVc' + }, + validator_3: { + privateKey: 'EKEqLGiiuaZwAV5XZeWGWBsQUmBCXAWR5zzq2vZtyCXou7ZYwryi', + publicKey: 'B62qjM9WyCn9BK2jyv6KkuLeXqiWsvaFPNtkNt9snt7U1TKxcZq9q7P' + } } - - let tokenKey = PrivateKey.fromBase58(allConfig["token"].privateKey); let adminContractKey = PrivateKey.fromBase58(allConfig["adminContract"].privateKey); let bridgeContractKey = PrivateKey.fromBase58(allConfig["bridgeContract"].privateKey); @@ -124,31 +131,30 @@ let validatorManagerContract = new ValidatorManager(validatorManagerAddress) await fetchAccount({publicKey: managerAddress}); await fetchAccount({publicKey: validatorManagerAddress}); -const x1 = await validatorManagerContract.validator1X.get(); -console.log("🚀 ~ x1:", x1) - -const admin = await managerContract.admin.get(); -console.log("🚀 ~ admin:", admin) - const symbol = 'WETH'; const src = "https://github.com/MinaFoundation/mina-fungible-token/blob/main/FungibleToken.ts"; const supply = UInt64.from(21_000_000_000_000) -const seed1 = allConfig['validator_1'].seed; -let privateKey = Secp256k1.Scalar.from(seed1); -let publicKey = Secp256k1.generator.scale(privateKey); +const validator1Privkey = PrivateKey.fromBase58(allConfig.validator_1.privateKey); +const validator2Privkey = PrivateKey.fromBase58(allConfig.validator_2.privateKey); +const validator3Privkey = PrivateKey.fromBase58(allConfig.validator_3.privateKey); +const validator1 = validator1Privkey.toPublicKey(); +const validator2 = validator2Privkey.toPublicKey(); +const validator3 = validator3Privkey.toPublicKey(); let amount = UInt64.from(2_000_000_000_000); // let receiver = PublicKey.fromBase58("B62qmHMUwiyNfv81NNTumW7Hv8SfRAGLXceGK3ZpyzXgmg2FLqmVhmA"); let receiver = PublicKey.fromBase58("B62qjWwgHupW7k7fcTbb2Kszp4RPYBWYdL4KMmoqfkMH3iRN2FN8u5n"); -let msg = Bytes256.fromString(`unlock receiver = ${receiver.toFields} amount = ${amount.toFields} tokenAddr = ${tokenAddress.toFields}`); - -let signature = Ecdsa.sign(msg.toBytes(), privateKey.toBigInt()); - +const msg = [ + ...receiver.toFields(), + ...amount.toFields(), + ...tokenAddress.toFields(), +] +const signature = await Signature.create(validator1Privkey, msg); let sentTx; // compile the contract to create prover keys @@ -166,15 +172,14 @@ try { UInt64.from(1), tokenAddress, Bool(true), + validator1, signature, - publicKey, Bool(false), + validator2, signature, - publicKey, Bool(false), + validator3, signature, - publicKey, - ); } );