A Rust blockchain library that provides the building blocks for creating a full-fledged blockchain application or platform, allowing you to focus on the higher-level features of your application without worrying about the low-level details of block validation
, data serialization
, and cryptographic operations
.
Record Trait ``` fn main() { use blockify::{sec, trans::record::Record}; use serde::{Deserialize, Serialize};
// Serialize and Deserialize are a supertrait of Record
struct Vote { session: i32, choice: i32, }
// Generate a new keypair let keypair = sec::generateed25519key_pair();
// Clone the public key let pubkey = keypair.clone().intopublic_key();
// Create a new Vote
instance
let my_record = Vote {
session: 0,
choice: 2,
};
// calculate the hash of myrecord let myrecordhash = sec::hash(&myrecord);
// sign myrecord with the AuthKeyPair instance and obtain a digital signature let signature = myrecord.sign(&keypair).unwrap();
// verify the authencity of the digital signature assert!(myrecord.verify(&signature, &pubkey).is_ok());
// record the myvote (convert it into a SignedRecord instance) let signedrecord = my_record.record(keypair).unwrap();
// Compare the signature of my_record
with that inside the SignedRecord
instance
asserteq!(&signature, signedrecord.signature());
// Compare the public key used to sign myrecord with that inside the SignedRecord
instance.
asserteq!(&pubkey, signedrecord.signer());
// Compare the hash of myrecord with that inside the SignedRecord
instance.
asserteq!(&myrecordhash, signed_record.hash());
// Verfify the signature within the SignedRecord
instance.
assert!(signedrecord.verify().isok());
}
```
All forms of contributions are gladly welcome.
MIT