Skip to content

Commit

Permalink
Allow SpendValidatingKey to be constructed from bytes
Browse files Browse the repository at this point in the history
closes #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
  • Loading branch information
pacu committed Jul 29, 2024
1 parent 2b9c9a1 commit 96bda92
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### added
- Added [Visibility crate](https://crates.io/crates/visibility) to modify
visibility of methods and struct for the `unstable-frost` feature.
- Added `SpendValidatingKey` serialization and deserialization from bytes
visibility under the `unstable-frost` feature
- `orchard::keys::SpendValidatingKey`

## [0.8.0] - 2024-03-25

Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ zcash_note_encryption = "0.4"
incrementalmerkletree = "0.5"
zcash_spec = "0.1"
zip32 = "0.1"
visibility = "0.1.0"

# Logging
tracing = "0.1"
Expand All @@ -71,6 +72,7 @@ bench = false

[features]
default = ["multicore"]
unstable-frost = []
multicore = ["halo2_proofs/multicore"]
dev-graph = ["halo2_proofs/dev-graph", "image", "plotters"]
test-dependencies = ["proptest"]
Expand Down
5 changes: 5 additions & 0 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,17 @@ impl SpendValidatingKey {

/// Converts this spend validating key to its serialized form,
/// I2LEOSP_256(ak).
#[cfg_attr(feature = "unstable-frost", visibility::make(pub))]
pub(crate) fn to_bytes(&self) -> [u8; 32] {
// This is correct because the wrapped point must have ỹ = 0, and
// so the point repr is the same as I2LEOSP of its x-coordinate.
<[u8; 32]>::from(&self.0)
}

/// 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_attr(feature = "unstable-frost", visibility::make(pub))]
pub(crate) fn from_bytes(bytes: &[u8]) -> Option<Self> {
<[u8; 32]>::try_from(bytes)
.ok()
Expand Down

0 comments on commit 96bda92

Please sign in to comment.