Fix signature schema and use a single initial guardian in ETH

Change-Id: Ia1995df4ed8f86443cdd62acee7914ffc745d407
This commit is contained in:
Hendrik Hofstadt 2021-06-30 22:04:12 +02:00
parent 62f5cb1986
commit f665fe4c7b
3 changed files with 71 additions and 80 deletions

View File

@ -70,15 +70,15 @@ contract Messages is Getters {
index += 1;
vm.signatures = new Structs.Signature[](signersLen);
for (uint i = 0; i < signersLen; i++) {
vm.signatures[i].guardianIndex = encodedVM.toUint8(index);
index += 1;
vm.signatures[i].r = encodedVM.toBytes32(index);
index += 32;
vm.signatures[i].s = encodedVM.toBytes32(index);
index += 32;
vm.signatures[i].v = encodedVM.toUint8(index) + 27;
index += 1;
vm.signatures[i].guardianIndex = encodedVM.toUint8(index);
index += 1;
}
// Hash the body

View File

@ -3,8 +3,7 @@ const Wormhole = artifacts.require("Wormhole");
const initialSigners = [
// testSigner 1 & 2
"0x7b6FA3F2bEb40eAf9Cefcb20505163C70d76f21c",
"0x4ba0C2db9A26208b3bB1a50B01b16941c10D76db",
"0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe",
]
const chainId = "0x2";
const governanceChainId = "0x3";

View File

@ -6,7 +6,7 @@ const Wormhole = artifacts.require("Wormhole");
const MockImplementation = artifacts.require("MockImplementation");
const Implementation = artifacts.require("Implementation");
const testSigner1PK = "13b422ac887f1912629e34928674cb4a81e59d96a4d74653e41c2a305ba754a5";
const testSigner1PK = "cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0";
const testSigner2PK = "892330666a850761e7370376430bb8c2aa1494072d3bfeaed0c4fa3d5a9135fe";
const testSigner3PK = "87b45997ea577b93073568f06fc4838cffc1d01f90fc4d57f936957f3c4d99fb";
@ -68,9 +68,8 @@ contract("Wormhole", function () {
const set = (await initialized.methods.getGuardianSet(index).call());
// check set
assert.lengthOf(set, 2);
assert.lengthOf(set[0], 1);
assert.equal(set[0][0], testSigner1.address);
assert.equal(set[0][1], testSigner2.address);
// check expiration
assert.equal(set.expirationTime, "0");
@ -154,7 +153,6 @@ contract("Wormhole", function () {
data,
[
testSigner1PK,
testSigner2PK
],
0
);
@ -206,7 +204,6 @@ contract("Wormhole", function () {
data,
[
testSigner1PK,
testSigner2PK
],
0
);
@ -288,7 +285,6 @@ contract("Wormhole", function () {
data,
[
testSigner1PK,
testSigner2PK
],
0
);
@ -339,7 +335,6 @@ contract("Wormhole", function () {
data,
[
testSigner1PK,
testSigner2PK
],
0
);
@ -449,7 +444,6 @@ contract("Wormhole", function () {
data,
[
testSigner1PK,
testSigner2PK
],
0
);
@ -485,7 +479,6 @@ contract("Wormhole", function () {
data,
[
testSigner1PK,
testSigner2PK
],
0
);
@ -631,7 +624,6 @@ const signAndEncodeVM = async function(
emitterAddress,
sequence,
data,
signers,
guardianSetIndex
) {
@ -654,10 +646,10 @@ const signAndEncodeVM = async function(
const signature = key.sign(hash.substr(2), {canonical: true});
const packSig = [
web3.eth.abi.encodeParameter("uint8", i).substring(2 + (64 - 2)),
zeroPadBytes(signature.r.toString(16), 32),
zeroPadBytes(signature.s.toString(16), 32),
web3.eth.abi.encodeParameter("uint8", signature.recoveryParam).substr(2 + (64 - 2)),
web3.eth.abi.encodeParameter("uint8", i).substring(2 + (64 - 2))
]
signatures += packSig.join("")