-
Notifications
You must be signed in to change notification settings - Fork 7
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
Signatures for Commits & the Author model #14
Comments
I've implemented a version of this process in atomic. Perhaps the most important step of this process is the serialization of the commit, since this process needs to be deterministic. This is what I'm doing now: /// Generates a deterministic serialized JSON representation of the Commit.
/// Does not contain the signature, since this function is used to check if the signature is correct.
pub fn serialize_deterministically(&self) -> AtomicResult<String> {
let mut obj = serde_json::Map::new();
obj.insert(
"subject".into(),
serde_json::Value::String(self.subject.clone()),
);
obj.insert(
"createdAt".into(),
serde_json::Value::Number(self.created_at.into()),
);
obj.insert(
"signer".into(),
serde_json::Value::String(self.signer.clone()),
);
if let Some(set) = self.set.clone() {
if !set.is_empty() {
let mut collect: Vec<(String, String)> = set.into_iter().collect();
// All keys should be ordered alphabetically
collect.sort();
// Make sure that the serializer does not mess up the order!
let mut set_map = serde_json::Map::new();
for (k, v) in collect.iter() {
set_map.insert(k.into(), serde_json::Value::String(v.into()));
}
obj.insert("set".into(), serde_json::Value::Object(set_map));
}
}
if let Some(mut remove) = self.remove.clone() {
if !remove.is_empty() {
// These, too, should be sorted alphabetically
remove.sort();
obj.insert("remove".into(), remove.into());
}
}
if let Some(destroy) = self.destroy {
// Only include this key if it is true
if destroy {
obj.insert("destroy".into(), serde_json::Value::Bool(true));
}
}
let string = serde_json::to_string(&obj)?;
Ok(string)
} Couple of thoughts / dilemmas:
|
I've updated the docs about this discussion. Long story short, I've opted for deterministic JSON-AD serialization and made two implementations (one in rust and one in typescript) |
In Atomic Commits, every change is signed by some author. This makes Commits truly atomic, and means that they can be shared as fully verifiable pieces of information, similar to W3C Verifiable Credentials (although Atomic Commits are specifically made to describe changes instead of current state).
However, this requires some implementation. Here's what I'm thinking:
The text was updated successfully, but these errors were encountered: