Minimal API changes for Issuance in Client (#43)

Make IVK::from_bytes public
This commit is contained in:
Alexey 2023-02-09 12:44:25 +01:00 committed by GitHub
parent cec48d72a1
commit 4e4767789e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -277,7 +277,10 @@ impl IssuanceValidatingKey {
<[u8; 32]>::from(&self.0)
}
pub(crate) fn from_bytes(bytes: &[u8]) -> Option<Self> {
/// Constructs an Orchard issuance validating key from uniformly-random bytes.
///
/// Returns `None` if the bytes do not correspond to a valid key.
pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
<[u8; 32]>::try_from(bytes)
.ok()
.and_then(check_structural_validity)

View File

@ -22,7 +22,7 @@ pub type Binding = reddsa::orchard::Binding;
impl SigType for Binding {}
/// A RedPallas signing key.
#[derive(Clone, Debug)]
#[derive(Clone, Copy, Debug)]
pub struct SigningKey<T: SigType>(reddsa::SigningKey<T>);
impl<T: SigType> From<SigningKey<T>> for [u8; 32] {

View File

@ -74,11 +74,11 @@ fn prepare_keys() -> Keychain {
fn sign_issue_bundle(
unauthorized: IssueBundle<Unauthorized>,
mut rng: OsRng,
isk: IssuanceAuthorizingKey,
isk: &IssuanceAuthorizingKey,
) -> IssueBundle<Signed> {
let sighash = unauthorized.commitment().into();
let proven = unauthorized.prepare(sighash);
proven.sign(&mut rng, &isk).unwrap()
proven.sign(&mut rng, isk).unwrap()
}
fn build_and_sign_bundle(
@ -159,7 +159,7 @@ fn issue_zsa_notes(asset_descr: &str, keys: &Keychain) -> (Note, Note) {
)
.is_ok());
let issue_bundle = sign_issue_bundle(unauthorized, rng, keys.isk().clone());
let issue_bundle = sign_issue_bundle(unauthorized, rng, keys.isk());
// Take notes from first action
let notes = issue_bundle.get_all_notes();