Skip to content

Commit

Permalink
feat: Add Schnorr Signatures (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxgst authored Jan 27, 2025
1 parent e221e8a commit 0fcc3b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions service/pool/IC.mo
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ module {
message_hash : Blob;
};
public type sign_with_ecdsa_result = { signature : Blob };
public type schnorr_algorithm = {
#bip340secp256k1;
#ed25519;
};
public type schnorr_aux = {
#bip341: {
merkle_root_hash: Blob
}
};
public type sign_with_schnorr_args = {
message : Blob;
derivation_path : [Blob];
key_id : { algorithm : schnorr_algorithm; name : Text };
aux: ?schnorr_aux;
};
public type sign_with_schnorr_result = { signature : Blob };
public type user_id = Principal;
public type wasm_module = Blob;
public type Self = actor {
Expand Down Expand Up @@ -116,6 +132,7 @@ module {
} -> async ();
raw_rand : shared () -> async Blob;
sign_with_ecdsa : shared sign_with_ecdsa_args -> async sign_with_ecdsa_result;
sign_with_schnorr : shared sign_with_schnorr_args -> async sign_with_schnorr_result;
start_canister : shared { canister_id : canister_id } -> async ();
stop_canister : shared { canister_id : canister_id } -> async ();
uninstall_code : shared { canister_id : canister_id } -> async ();
Expand Down
8 changes: 8 additions & 0 deletions service/pool/Main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
await* pool.addCycles(caller, #refund);
res
};
public shared ({ caller }) func sign_with_schnorr(arg: ICType.sign_with_schnorr_args) : async ICType.sign_with_schnorr_result {
await* pool.addCycles(caller, #method "sign_with_schnorr");
let res = await IC.sign_with_schnorr(arg);
await* pool.addCycles(caller, #refund);
res
};
public shared ({ caller }) func _ttp_request(request : ICType.http_request_args) : async ICType.http_request_result {
await* pool.addCycles(caller, #method "http_request");
let new_request = switch (request.transform) {
Expand Down Expand Up @@ -831,6 +837,7 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
#_ttp_request : Any;
#__transform : Any;
#sign_with_ecdsa: Any;
#sign_with_schnorr: Any;
#eth_call: Any;
#eth_feeHistory: Any;
#eth_getBlockByNumber: Any;
Expand All @@ -855,6 +862,7 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
case (#_ttp_request _) false;
case (#__transform _) false;
case (#sign_with_ecdsa _) false;
case (#sign_with_schnorr _) false;
case (#eth_call _) false;
case (#eth_feeHistory _) false;
case (#eth_getBlockByNumber _) false;
Expand Down

0 comments on commit 0fcc3b9

Please sign in to comment.