Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/subcmds/plog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub async fn go(cmd: Command, _config: &Config) -> Result<(), Error> {
.hash(vlad_cid_hash)
.build(),
)
.entrykey(parse_key_params(&entry_key_codec, Some("/entrykey"))?)
.first_entry_params(parse_key_params(&entry_key_codec, Some("/entrykey"))?)
.unlock(unlock_script)
.lock(lock_script.clone())
.additional_ops(additional_ops) // Add all operations at once
Expand Down
4 changes: 2 additions & 2 deletions crates/bs-peer/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ where

// Create BetterSign instance (no lock held)
let bs = BetterSign::new(
config.clone(),
&config,
self.key_provider.clone(),
self.key_provider.clone(),
)
Expand Down Expand Up @@ -341,7 +341,7 @@ where
.build()
.into(),
)
.entrykey(
.first_entry_params(
FirstEntryKeyParams::builder()
.codec(Codec::Ed25519Priv)
.build()
Expand Down
4 changes: 2 additions & 2 deletions crates/bs-peer/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub async fn run_in_memory_blockstore_test() {
.build()
.into(),
)
.entrykey(
.first_entry_params(
FirstEntryKeyParams::builder()
.codec(Codec::Ed25519Priv)
.build()
Expand Down Expand Up @@ -376,7 +376,7 @@ pub async fn run_network_blockstore_test() {
.build()
.into(),
)
.entrykey(
.first_entry_params(
FirstEntryKeyParams::builder()
.codec(Codec::Ed25519Priv)
.build()
Expand Down
20 changes: 10 additions & 10 deletions crates/bs/src/better_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ where
S: MultiSigner<E>,
{
/// Create a new BetterSign instance with the given configuration.
pub async fn new(config: open::Config, mut key_manager: KM, signer: S) -> Result<Self, E> {
let plog = open::open_plog_core(&config, &mut key_manager, &signer).await?;
pub async fn new(config: &open::Config, mut key_manager: KM, signer: S) -> Result<Self, E> {
let plog = open::open_plog_core(config, &mut key_manager, &signer).await?;
Ok(Self {
plog,
key_manager,
Expand Down Expand Up @@ -110,7 +110,7 @@ where
/// # Errors
///
/// Returns an error if the provenance log creation fails.
pub fn new_sync(config: open::Config, key_manager: KM, signer: S) -> Result<Self, E> {
pub fn new_sync(config: &open::Config, key_manager: KM, signer: S) -> Result<Self, E> {
futures::executor::block_on(Self::new(config, key_manager, signer))
}

Expand Down Expand Up @@ -146,7 +146,7 @@ mod tests {
.build()
.into(),
)
.entrykey(
.first_entry_params(
FirstEntryKeyParams::builder()
.codec(Codec::Ed25519Priv)
.build()
Expand All @@ -165,7 +165,7 @@ mod tests {
let key_manager = InMemoryKeyManager::<Error>::default();
let signer = key_manager.clone();

let bs = BetterSign::new(config, key_manager, signer)
let bs = BetterSign::new(&config, key_manager, signer)
.await
.expect("Failed to create BetterSign");

Expand All @@ -184,7 +184,7 @@ mod tests {
.build()
.into(),
)
.entrykey(
.first_entry_params(
FirstEntryKeyParams::builder()
.codec(Codec::Ed25519Priv)
.build()
Expand All @@ -203,7 +203,7 @@ mod tests {
let key_manager = InMemoryKeyManager::<Error>::default();
let signer = key_manager.clone();

let mut bs = BetterSign::new(open_config, key_manager, signer)
let mut bs = BetterSign::new(&open_config, key_manager, signer)
.await
.expect("Failed to create BetterSign");

Expand Down Expand Up @@ -239,7 +239,7 @@ mod tests {
.build()
.into(),
)
.entrykey(
.first_entry_params(
FirstEntryKeyParams::builder()
.codec(Codec::Ed25519Priv)
.build()
Expand All @@ -258,8 +258,8 @@ mod tests {
let key_manager = InMemoryKeyManager::<Error>::default();
let signer = key_manager.clone();

let bs =
BetterSign::new_sync(config, key_manager, signer).expect("Failed to create BetterSign");
let bs = BetterSign::new_sync(&config, key_manager, signer)
.expect("Failed to create BetterSign");

// Verify the plog was created
assert!(!bs.plog().entries.is_empty());
Expand Down
4 changes: 2 additions & 2 deletions crates/bs/src/ops/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ where
key_manager.preprocess_vlad(&vlad).await?;

// 2. Extract entry key parameters and prepare signing
let entrykey_params = &config.entrykey();
let entrykey_params = &config.first_entry();
let (codec, threshold, limit) = extract_key_params::<E>(entrykey_params)?;

// Get the public key and signing function
Expand Down Expand Up @@ -430,7 +430,7 @@ mod tests {
let config = Config::builder() // Uses default type parameter FirstEntryKeyParams
.vlad(vlad_params)
.pubkey(pubkey_params.into())
.entrykey(entry_key_params.into())
.first_entry_params(entry_key_params.into())
.lock(Script::Code(Key::default(), lock))
.unlock(Script::Code(Key::default(), unlock))
.build();
Expand Down
31 changes: 19 additions & 12 deletions crates/bs/src/ops/open/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub struct Config<T: ValidatedKeyParams = FirstEntryKeyParams> {
/// the vlad key and cid params
vlad: VladParams<T>,

/// the entry key params
entrykey: OpParams,
/// First entry [OpParams]
first_entry_params: OpParams,

/// the pubkey params
pubkey: OpParams,
Expand Down Expand Up @@ -46,9 +46,11 @@ impl<T: ValidatedKeyParams> Config<T> {
&self.first_lock
}

/// Get the entry key params
pub fn entrykey(&self) -> &OpParams {
&self.entrykey
/// Get the (first) entry key params
///
/// Because this is the Open Config, this will always be the first entry
pub fn first_entry(&self) -> &OpParams {
&self.first_entry_params
}

/// Get the pubkey params
Expand Down Expand Up @@ -87,7 +89,12 @@ impl<T: ValidatedKeyParams> From<Config<T>> for Vec<OpParams> {
// Gather all the operations from this config so we can store their values against their Cids
let (vlad_key_op, vlad_cid_op): (OpParams, OpParams) = config.vlad.into();

let mut ops = vec![vlad_key_op, vlad_cid_op, config.entrykey, config.pubkey];
let mut ops = vec![
vlad_key_op,
vlad_cid_op,
config.first_entry_params,
config.pubkey,
];
ops.extend(config.additional_ops);
ops
}
Expand All @@ -107,7 +114,7 @@ mod tests {
// Create a Config with default type parameter (FirstEntryKeyParams)
let config = Config::builder()
.vlad(Default::default())
.entrykey(Default::default())
.first_entry_params(Default::default())
.pubkey(Default::default())
.lock(Script::Code(Key::default(), "test lock".to_string()))
.unlock(Script::Code(Key::default(), "test unlock".to_string()))
Expand All @@ -126,7 +133,7 @@ mod tests {
fn test_config_with_recovery_key_params() {
let config: Config<RecoveryKeyParams> = Config::<RecoveryKeyParams>::builder()
.vlad(VladParams::<RecoveryKeyParams>::builder().build())
.entrykey(Default::default())
.first_entry_params(Default::default())
.pubkey(Default::default())
.lock(Script::Code(Key::default(), "test lock".to_string()))
.unlock(Script::Code(Key::default(), "test unlock".to_string()))
Expand All @@ -150,7 +157,7 @@ mod tests {
// Create Config and set VladParams
let config = Config::<FirstEntryKeyParams>::builder()
.vlad(Default::default())
.entrykey(Default::default())
.first_entry_params(Default::default())
.pubkey(Default::default())
.lock(Script::Code(Key::default(), "test lock".to_string()))
.unlock(Script::Code(Key::default(), "test unlock".to_string()))
Expand All @@ -177,7 +184,7 @@ mod tests {
// Create a Config
let config = Config::builder()
.vlad(Default::default())
.entrykey(Default::default())
.first_entry_params(Default::default())
.pubkey(Default::default())
.lock(Script::Code(Key::default(), "test lock".to_string()))
.unlock(Script::Code(Key::default(), "test unlock".to_string()))
Expand All @@ -199,7 +206,7 @@ mod tests {
// Create a Config
let config = Config::builder()
.vlad(Default::default())
.entrykey(Default::default())
.first_entry_params(Default::default())
.pubkey(Default::default())
.lock(Script::Code(Key::default(), "test lock".to_string()))
.unlock(Script::Code(Key::default(), "test unlock".to_string()))
Expand All @@ -219,7 +226,7 @@ mod tests {
// This would be a compile error if we tried to use the wrong type
let config = Config::<FirstEntryKeyParams>::builder()
.vlad(vlad_params)
.entrykey(Default::default())
.first_entry_params(Default::default())
.pubkey(Default::default())
.lock(Script::Code(Key::default(), "test lock".to_string()))
.unlock(Script::Code(Key::default(), "test unlock".to_string()))
Expand Down
2 changes: 1 addition & 1 deletion crates/bs/src/ops/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ mod tests {
let open_config = open::Config::builder()
.vlad(VladParams::<FirstEntryKeyParams>::default())
.pubkey(pubkey_params.clone().into())
.entrykey(
.first_entry_params(
FirstEntryKeyParams::builder()
.codec(Codec::Ed25519Priv)
.build()
Expand Down