Rename associated -> endorsed across the account API

One verb everywhere, matching the log's own vocabulary: an account
endorses keys; the registry answers what is endorsed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jazz Turner-Baggs 2026-07-06 13:05:36 -07:00
parent 00e4047cf4
commit f301c01648
No known key found for this signature in database
4 changed files with 27 additions and 22 deletions

View File

@ -50,7 +50,7 @@ impl TestAccountService {
impl AccountRegistry for TestAccountService {
type Error = AccountError;
fn associated_ed25519_keys(
fn endorsed_ed25519_keys(
&self,
addr: &AccountAddr,
) -> Result<Option<Vec<Ed25519VerifyingKey>>, Self::Error> {
@ -112,7 +112,7 @@ impl TestLogosAccount {
&self.addr
}
pub fn associate_ed25519_signer(
pub fn endorse_ed25519_signer(
&mut self,
key: &Ed25519VerifyingKey,
) -> Result<(), AccountError> {
@ -141,18 +141,18 @@ mod tests {
Ed25519SigningKey::generate().verifying_key()
}
/// associate → the shared service resolves the key for that account.
/// endorse → the shared service resolves the key for that account.
#[test]
fn associated_signer_is_resolvable() {
fn endorsed_signer_is_resolvable() {
let srv = TestAccountService::new();
let mut account = srv.account();
let dev = device();
account.associate_ed25519_signer(&dev).unwrap();
account.endorse_ed25519_signer(&dev).unwrap();
assert!(srv.is_ed25519_associated(&dev, account.address()).unwrap());
assert!(srv.is_ed25519_endorsed(&dev, account.address()).unwrap());
assert!(
!srv.is_ed25519_associated(&device(), account.address())
!srv.is_ed25519_endorsed(&device(), account.address())
.unwrap()
);
}
@ -163,24 +163,24 @@ mod tests {
let srv = TestAccountService::new();
let account = srv.account();
assert!(
srv.associated_ed25519_keys(account.address())
srv.endorsed_ed25519_keys(account.address())
.unwrap()
.is_none()
);
}
/// Each associate extends the log; the registry sees the full key set.
/// Each endorsement extends the log; the registry sees the full key set.
#[test]
fn associations_accumulate() {
fn endorsements_accumulate() {
let srv = TestAccountService::new();
let mut account = srv.account();
let (a, b) = (device(), device());
account.associate_ed25519_signer(&a).unwrap();
account.associate_ed25519_signer(&b).unwrap();
account.endorse_ed25519_signer(&a).unwrap();
account.endorse_ed25519_signer(&b).unwrap();
let keys = srv
.associated_ed25519_keys(account.address())
.endorsed_ed25519_keys(account.address())
.unwrap()
.unwrap();
assert_eq!(keys, vec![a, b]);

View File

@ -1,5 +1,5 @@
//! Signed account operation log: the append-only record of an account's
//! associated key and data.
//! Signed account operation log: the append-only record of the keys and data
//! an account has endorsed.
//!
//! ```text
//! SignedAccountLog payload + account signature over its exact bytes

View File

@ -135,11 +135,13 @@ fn decode_entries(payload: &[u8]) -> Result<Vec<AccountEntry>, AccountLogError>
/// Parse one entry off the front of `body`, returning it and the rest.
fn decode_entry(body: &[u8]) -> Result<(AccountEntry, &[u8]), AccountLogError> {
let (&tag, body) = body.split_first()
let (&tag, body) = body
.split_first()
.ok_or_else(|| malformed("payload shorter than its declared layout"))?;
match tag {
TAG_ADD => {
let (&data_tag, body) = body.split_first()
let (&data_tag, body) = body
.split_first()
.ok_or_else(|| malformed("payload shorter than its declared layout"))?;
match data_tag {
DATA_ED25519 => {
@ -204,7 +206,10 @@ pub fn verify_log(
/// The server runs this on publish to refuse stale or rewritten logs, and
/// consumers run it against the last log they saw as defence in depth. It
/// compares bytes, so the server needs no knowledge of entry semantics.
pub fn verify_extension(old: &EncodedAccountLog, new: &EncodedAccountLog) -> Result<(), AccountLogError> {
pub fn verify_extension(
old: &EncodedAccountLog,
new: &EncodedAccountLog,
) -> Result<(), AccountLogError> {
if new.count() <= old.count() {
return Err(AccountLogError::Stale);
}

View File

@ -36,20 +36,20 @@ pub trait AccountRegistry {
type Error: std::fmt::Display + std::fmt::Debug;
/// Keys currently endorsed by `addr`. `Ok(None)`: account never published.
fn associated_ed25519_keys(
fn endorsed_ed25519_keys(
&self,
addr: &AccountAddr,
) -> Result<Option<Vec<Ed25519VerifyingKey>>, Self::Error>;
/// Is `signer` currently endorsed by `addr`? Provided — one derivation,
/// so implementations cannot diverge on what "associated" means.
fn is_ed25519_associated(
/// so implementations cannot diverge on what "endorsed" means.
fn is_ed25519_endorsed(
&self,
signer: &Ed25519VerifyingKey,
addr: &AccountAddr,
) -> Result<bool, Self::Error> {
Ok(self
.associated_ed25519_keys(addr)?
.endorsed_ed25519_keys(addr)?
.is_some_and(|keys| keys.contains(signer)))
}
}