Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions packages/wasm-mps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ mod mps {
pub struct Share {
pub share: Vec<u8>,
pub pk: [u8; 32],
pub chaincode: [u8; 32],
}

fn internal_dkg_round0_process<G>(
Expand Down Expand Up @@ -279,6 +280,7 @@ mod mps {
Ok(Share {
share: bincode::serialize(&share).map_err(|_| MpsError::SerializationError)?,
pk: share.public_key.compress().to_bytes(),
chaincode: share.root_chain_code,
})
}

Expand Down Expand Up @@ -525,14 +527,22 @@ mod tests {
)
.unwrap();

// Assert generated public keys are equal
// Assert generated public keychains are equal
assert_eq!(
p2_share.pk, p0_share.pk,
"Party 0 share differs from party 2 share"
"Party 0 public key differs from party 2 public key"
);
assert_eq!(
p2_share.pk, p1_share.pk,
"Party 1 share differs from party 2 share"
"Party 1 public key differs from party 2 public key"
);
assert_eq!(
p2_share.chaincode, p0_share.chaincode,
"Party 0 chaincode differs from party 2 chaincode"
);
assert_eq!(
p2_share.chaincode, p1_share.chaincode,
"Party 1 chaincode differs from party 2 chaincode"
);
}

Expand Down Expand Up @@ -697,6 +707,7 @@ impl MsgState {
pub struct Share {
share: Vec<u8>,
pk: Vec<u8>,
chaincode: Vec<u8>,
}

#[wasm_bindgen]
Expand All @@ -710,6 +721,11 @@ impl Share {
pub fn pk(&self) -> Vec<u8> {
self.pk.clone()
}

#[wasm_bindgen(getter)]
pub fn chaincode(&self) -> Vec<u8> {
self.chaincode.clone()
}
}

#[wasm_bindgen]
Expand All @@ -730,6 +746,7 @@ impl MsgShare {
Share {
share: self.share.share.clone(),
pk: self.share.pk.clone(),
chaincode: self.share.chaincode.clone(),
}
}
}
Expand Down Expand Up @@ -796,6 +813,7 @@ pub fn ed25519_dkg_round2_process(round2_messages: Array, state: &[u8]) -> Resul
Ok(Share {
share: result.share,
pk: result.pk.to_vec(),
chaincode: result.chaincode.to_vec(),
})
}

Expand Down
3 changes: 3 additions & 0 deletions packages/wasm-mps/test/mps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ describe("mps", function () {
);
for (let i = 0; i < 2; i++) {
assert.ok(results3[i].pk.every((value, index) => value === results3[2].pk[index]));
assert.ok(
results3[i].chaincode.every((value, index) => value === results3[2].chaincode[index]),
);
}
});

Expand Down
Loading