Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
change signing function
Browse files Browse the repository at this point in the history
Signed-off-by: Dominic Woerner <dominic.woerner@dfinity.org>
  • Loading branch information
domwoe committed Jan 19, 2024
1 parent f4ab2ed commit 3a94ac8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Once the job completes, your application will be available at `http://localhost:
## ToDos

- [ ] Implement key derivation
- [ ] Require cycles
- [ ] Try to get rid of `getrandom` dependency or provide proper implementation of custom function
- [ ] Try to init key in `init` function. Maybe with timer.

Expand Down
5 changes: 5 additions & 0 deletions canister_ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"schnorr_canister_backend": {
"ic": "htvbm-vaaaa-aaaap-qb5kq-cai"
}
}
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bip32::{Seed, XPrv};
use candid::{CandidType, Deserialize, Principal};
use k256::ecdsa::signature::hazmat::PrehashSigner;
use k256::ecdsa::signature::Signer;
use serde::Serialize;

use ic_stable_structures::memory_manager::{MemoryId, MemoryManager, VirtualMemory};
Expand Down Expand Up @@ -164,10 +164,12 @@ fn sign_with_schnorr(arg: SignWithSchnorr) -> SignWithSchnorrReply {

let signing_key = k256::schnorr::SigningKey::from_bytes(key_bytes.as_slice()).unwrap();

let signature = match signing_key.sign_prehash(message_hash.as_slice()) {
Ok(signature) => signature,
Err(_err) => ic_cdk::trap("Error signing message"),
};
// let signature = match signing_key.sign_prehash(message_hash.as_slice()) {
// Ok(signature) => signature,
// Err(_err) => ic_cdk::trap("Error signing message"),
// };

let signature = signing_key.sign(message_hash.as_slice());

SignWithSchnorrReply {
signature: signature.to_bytes().to_vec(),
Expand Down

0 comments on commit 3a94ac8

Please sign in to comment.