1 unstable release
new 0.9.0 | Feb 25, 2025 |
---|
#426 in Cryptography
Used in 2 crates
(via flmodules)
190KB
4.5K
SLoC
Crypto Wrappers
This crypto wrapper defines the following main structures:
Signer
- a generic structure to sign messagesVerifier
- a generic structure to verify signed messagesCondition
- an AND/OR/NofT combination of verifiersIdentity
- an updatable pair ofsign
andupdate
Conditions, representing identities or cryptographic anchors
An example use-case is the following:
- When a node starts, it creates a
Signer
, and aIdentity
with aCondition
pointing to thatSigner
. This allows the node to do key rotation by updating itsIdentity
- A user wants to create a website with many objects, so they create:
- one or more nodes with the corresponding
Identity
s. A CLI tool to update the page also acts as a node. - a
WebPageT: Identity
with an OR of all nodes and CLIsIdentity
s - a
WebPageAR: ACE
with rules likeupdate_object
,add_object
,rm_object
, pointing to theWebPageT
- one or more nodes with the corresponding
- Now the user can create objects and point them to the
WebPageAR
, allowing them to:- control all objects from any node
- update the
WebPageT
if nodes join or go away - update the
WebPageAR
if part of the rules should apply to otherIdentity
s. An example could be a rule to update theTTL
of an object, which could be allowed by more nodes than the rule to modify an object
Rule
Expression
The following structures are defined for signing and updating an expression:
struct ExpressionSignatureCollector {
expression_id,
msg,
signatures: HashMap<RuleID, Signature>,
#[serde(skip)]
ev_cache: Option<watch::Receiver<EVCache>>,
}
type RuleID = Hash(msg|RulePath|SignerID);
struct ExpressionUpdateCollector {
expression_id,
current_version,
new_rules,
sig: Either<ExpressionSignatureCollector, ExpressionSignature>,
}
Sign
Expression.signature_collector(msg)
->ExpressionSignatureCollector
ESC.sign(Signer)
->ExpressionSignatureCollector
ESC.finalize()
-> Result<(ExpressionSignature
,ExpressionSignatureVerifiers
),ESCError
>
Signing Subtrees
There might be a usecase for having more privacy-preserving signatures of sub-trees,
so that the signers cannot see the rest of the Expression
.
But the original msg
will still need to be verified in one way or another.
Verify
Expression.verify(msg, ES, ESV)
->Result<(), ESError>
Update
Expression.update_message(new_rules)
->msg
orExpression.update_collector(new_rules)
->ExpressionUpdateCollector
EUC.sign(Signer)
->ExpressionUpdateCollector
EUC.finalize()
->ExpressionUpdate
Expression.update(new_rules, ES)
->Expression
orExpression.update_finalize(EU)
->Expression
ACE
In an AccessRule
, the rules only point to ExpressionID
.
As such, whatever you want to do with an AccessRule
needs to have
access to the underlying Expression
s.
Not sure whether this should be a HashMap
, or better an asynchronous
expression_getter
.
Sign
Verify
Update
Dependencies
~9–26MB
~402K SLoC