Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SpendValidatingKey to be constructed from bytes #428

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

pacu
Copy link
Contributor

@pacu pacu commented Jul 5, 2024

According to the FROST book the ASK is split using FROST and its verifying key is the ak that should be used to generate the Orchard Full Viewing Key.

Allow SpendValidatingKey to be constructed from bytes

closes #427

As we agreed with @daira at Z|ECC, this adds a FROST feature flag so that public interface of the
crate is not altered in its meaning for non-FROST applications.

Key derivation is intended to be done on a specific way for usual
applications. Interface changes introduce by FROST can pose a risk
for the rest of the use cases that don't involve the assumptions
of the FROST signature scheme protocol. we don't want non-FROST
cases to make use the helper functions FROST needs to derive the
needed key elements.

There are other changes pending to make FROST work with Orchard.
Those changes will also be under this same feature flag

Copy link

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also interested this since we also need this for our FROST demo signing tool (we are currently using Ywallet code that uses modified versions of the crates so we just edited them to support this, but we're in the process of replacing that code).

I left a couple of random comments while I was taking a look, but it's probably better to wait for the maintainers to chime in first before changing anything.

src/keys.rs Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@str4d
Copy link
Contributor

str4d commented Jul 23, 2024

I'm fine with adding this kind of API behind an unstable cfg option, but I think that this API is not what we will want in the final production release, because I suspect we will not want people to pass around aks on their own (that will lead to partial loss of necessary details, and sadness).

To figure out the production API, we need to first finish the Key Generation part of ZIP 312. I'd started sketching that out in zcash/zips#662 (comment) which I will move into a separate PR; once we've figured that out, we can provide higher-level APIs in this crate that produce the actual types we need.

@pacu
Copy link
Contributor Author

pacu commented Jul 23, 2024

I suspect we will not want people to pass around aks on their own (that will lead to partial loss of necessary details, and sadness).

Yes this is exactly what we don't want for non-FROST users.

@str4d, What about adding the visibility crate to handle the API changes as @conradoplg suggested?

We'd be adding #[cfg_attr(feature = "frost", visibility::make(pub))] but this is probably a dependency that is not feature-gated because it has to compile even when the frost feature is not selected

src/keys.rs Outdated
Comment on lines 220 to 227

/// Attempts to convert these bytes into a spend validating key
/// from its serialized form, I2LEOSP_256(ak). Returns None if
/// it can't be created.
#[cfg(feature = "frost")]
pub fn with_bytes(bytes: &[u8]) -> Option<Self> {
SpendValidatingKey::from_bytes(bytes)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed if #[cfg_attr(feature = "frost", visibility::make(pub))] is used. In any case the method that is conditionally exposed should be called from_bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool I'll get visibility crate in then. Thank you!

CHANGELOG.md Outdated Show resolved Hide resolved
closes zcash#427

This adds a FROST feature flag so that public interface of the
crate is not altered in its meaning for non-FROST applications.

Key derivation is intended to be done on a specific way for usual
applications. Interface changes introduce by FROST can pose a risk
for the rest of the use cases that don't involve the assumptions
of the FROST signature scheme protocol. we don't want non-FROST
cases to make use the helper functions FROST needs to derive the
needed key elements.

PR suggestions:
	Make "frost" feature be under the "unstable" set of features
	correct the unstable feature definition
	use visibility crate
Copy link

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@str4d
Copy link
Contributor

str4d commented Aug 1, 2024

To figure out the production API, we need to first finish the Key Generation part of ZIP 312. I'd started sketching that out in zcash/zips#662 (comment) which I will move into a separate PR; once we've figured that out, we can provide higher-level APIs in this crate that produce the actual types we need.

I opened zcash/zips#883 as that separate PR. @conradoplg @pacu let's figure out and specify the FROST-Orchard key tree interaction there.

src/keys.rs Outdated Show resolved Hide resolved
str4d
str4d previously approved these changes Aug 1, 2024
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 96bda92 one the following changes are made.

CHANGELOG.md Outdated Show resolved Hide resolved
src/keys.rs Outdated Show resolved Hide resolved
daira
daira previously approved these changes Aug 1, 2024
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK with a non-blocking suggestion.

Co-authored-by: Jack Grigg <[email protected]>
Co-authored-by: Daira-Emma Hopwood <[email protected]>
@nuttycom nuttycom dismissed stale reviews from daira and str4d via 2bb3a08 August 1, 2024 16:57
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 2bb3a08

@str4d
Copy link
Contributor

str4d commented Aug 1, 2024

According to the FROST book the ASK is split using FROST and its verifying key is the ak that should be used to generate the Orchard Full Viewing Key.

Just to be very clear here, the FROST book is not normative, except as it is incorporated by reference into the protocol spec or a ZIP (which to my knowledge it is currently not). It is very informative, but any FROST logic we put into the public crates needs to be tied to a normative reference. In this case, that is ZIP 312, so anything we do needs to be specified there (i.e. in the PR I linked above).

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-utACK 2bb3a08

@nuttycom nuttycom merged commit d4136c6 into zcash:main Aug 1, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow SpendValidatingKey to be constructed from bytes
5 participants