pub struct LawPackage {
pub law_id: String,
pub name: String,
pub author_did: String,
pub licence: String,
pub nature: LawNature,
pub content_hash: String,
pub signature: Vec<u8>,
pub authored_at_unix: u64,
}Expand description
A signed law package (T72). Provenance travels with the law.
The package contains the law’s identity, authorship, licence, nature (physical vs fictional), content hash, and an Ed25519 signature by the author. The signature verifies that the author did indeed author this law package and that its content has not been tampered with.
Fields§
§law_id: StringThe law’s identifier (hash of its content).
name: StringHuman-readable name.
Author DID (who authored this law).
licence: StringLicence under which this law is published.
nature: LawNatureWhether this law is physical (grounded in physics) or fictional (narrative/game/simulation only).
content_hash: StringContent hash of the law’s formal definition.
signature: Vec<u8>Ed25519 signature by the author over the content hash.
Unix timestamp when the law was authored.
Implementations§
Source§impl LawPackage
impl LawPackage
Sourcepub fn new(
law_id: &str,
name: &str,
author_did: &str,
licence: &str,
nature: LawNature,
content_hash: &str,
authored_at_unix: u64,
) -> Self
pub fn new( law_id: &str, name: &str, author_did: &str, licence: &str, nature: LawNature, content_hash: &str, authored_at_unix: u64, ) -> Self
Create a new law package with the given metadata.
The signature should be set via set_signature.
Sourcepub fn set_signature(&mut self, signature: Vec<u8>)
pub fn set_signature(&mut self, signature: Vec<u8>)
Set the signature (typically after signing with the author’s private key).
Sourcepub fn sign(&mut self, signing_key: &SigningKey)
pub fn sign(&mut self, signing_key: &SigningKey)
Sign the package with the author’s Ed25519 signing key.
Sourcepub fn verify_signature(&self, public_key: &[u8]) -> bool
pub fn verify_signature(&self, public_key: &[u8]) -> bool
Verify the Ed25519 signature against the author’s public key.
Returns true if the signature is valid for this package’s
content hash, false otherwise (including if no signature is
set). Same dalek verifier on native and wasm32 — Ed25519 is
WASM-safe; a fail-closed stub would make signed law packages
unverifiable in the browser.
Trait Implementations§
Source§impl Clone for LawPackage
impl Clone for LawPackage
Source§impl Debug for LawPackage
impl Debug for LawPackage
Source§impl<'de> Deserialize<'de> for LawPackage
impl<'de> Deserialize<'de> for LawPackage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for LawPackage
impl RefUnwindSafe for LawPackage
impl Send for LawPackage
impl Sync for LawPackage
impl Unpin for LawPackage
impl UnsafeUnpin for LawPackage
impl UnwindSafe for LawPackage
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more