You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Generate signatures for P2PK inputs deterministically
174
+
///
175
+
/// Schnorr signatures need an unpredictable nonce added to the signature to avoid private key leakage. Normally this is generated using 32 bytes of entropy, but on platforms where that
176
+
/// is not available, `sign_transaction_deterministic` can be used to generate the nonce using a hash of the private key and message. \
177
+
/// Additionally `aux_rand` can be optionally supplied with up 32 bytes of entropy.
178
+
/// # Limitations
179
+
/// Only inputs that reduce to a single public key can be signed. Thus proveDhTuple, n-of-n and t-of-n signatures can not be produced using this method
use ergotree_ir::serialization::SigmaSerializable;
51
55
use ergotree_ir::sigma_protocol::dlog_group;
52
56
use ergotree_ir::sigma_protocol::sigma_boolean::ProveDlog;
53
-
use k256::Scalar;
57
+
use k256::elliptic_curve::ops::Reduce;
58
+
use k256::{ProjectivePoint,Scalar};
54
59
55
60
/// Step 5 from <https://ergoplatform.org/docs/ErgoScript.pdf>
56
61
/// For every leaf marked “simulated”, use the simulator of the sigma protocol for that leaf
@@ -85,6 +90,49 @@ pub mod interactive_prover {
85
90
(r.into(),FirstDlogProverMessage{a: a.into()})
86
91
}
87
92
93
+
/// Step 6 from <https://ergoplatform.org/docs/ErgoScript.pdf>
94
+
/// Generate first message "nonce" deterministically, optionally using auxilliary rng
95
+
/// # Safety
96
+
/// This is only intended to be used in single-signer scenarios.
97
+
/// Using this in multi-signature situations where other (untrusted) signers influence the signature can cause private key leakage by producing multiple signatures for the same message with the same nonce
98
+
pubfnfirst_message_deterministic(
99
+
sk:&DlogProverInput,
100
+
msg:&[u8],
101
+
aux_rand:&[u8],
102
+
) -> (Wscalar,FirstDlogProverMessage){
103
+
// This is based on BIP340 deterministic nonces, see: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#default-signing
// Perform domain seperation so alternative signature schemes don't end up producing the same nonce, for example ProveDHTuple with deterministic nonces
0 commit comments