使用旧Rust 2015
0.1.0 |
|
---|
#8 in #banner
115KB
2.5K SLoC
Libyobicash
Yobicash加密货币库。
目录
安装
要安装libyobicash,请将以下内容添加到您的Cargo.toml
# Cargo.toml
[dependencies]
libyobicash = "^0.1"
并在您的crate根目录中
//main.rs
extern crate libyobicash;
使用
查看文档或测试以获取指导。
// 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()?);
维护者
许可
此项目受以下任一许可证的许可
- Apache许可证2.0版本 (LICENSE-APACHE 或 http://www.apache.org/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
您可选择。
贡献
除非您明确说明,否则您根据Apache-2.0许可证定义的任何有意提交以包括在libyobicash中的贡献,均将按照上述方式双重许可,无需附加条款或条件。
依赖项
~13MB
~252K SLoC