Uses old Rust 2015
The Yobicash cryptocurrency library.
To install libyobicash add in your Cargo.toml:
# Cargo.toml [dependencies] libyobicash = "^0.1"
and in the root of your crate:
//main.rs extern crate libyobicash;
Look at the documentation or at the tests for guidance.
// main.rs // Bob wants to send some data to Alice through Yobicash and has found // a node offering a good price for broadcasting the data. // let plain = some super important secret. // let alice_pk = Alice public key; let bob_sk = SecretKey::random(); let bob_data = Data::new(bob_sk, alice_pk, &plain)?; // let bob_coins = some spendable coins Bob owns that pay the fee // required by the node; // let bob = the output to the node that will broadcast Bob writes operation; // One secret instance from Bob. Bob will use it to permit the network to // delete his data. let bob_instance = Scalar::random(); // The write operation containing the encrypted data that only // Bob and Alice can read. After confirmation, it will be broadcasted // to the network. let bob_write = WriteOp::new(&bob_coins, &bob_data, bob_instance, &bob_fee)?; println!(write_op.to_json()?); // Now that the secret is not needed anymore, Bob and Alice agree that it // can be erased from the dagchain. Bob finds a node with making a good offer // to get rid of that data and broadcast the operation to the network. // let node_coins = some spendable coins the node owns that pay Bob's fee; // let node_fee = the fee promised to Bob by the node; // Bob generates the proof of the bob_write witness instance to send to the node // using the fee that the node will use and bob_write itself. let bob_proof = DeleteOp::proof(&bob_write, &bob_instance, &node_fee)?; // The node creates a delete operation with Bob's witness. // The node will delete bob_writes' Data after node_delete get confirmed. // The other nodes of the network will do the same. let node_delete = DeleteOp::new(&node_coins, &bob_write, &bob_proof, &node_fee)?; println!(node_delete.to_json()?);
This project is license under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in libyobicash by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.