Skip to content

Commit

Permalink
docs: Generate README with cargo-rdme
Browse files Browse the repository at this point in the history
  • Loading branch information
vadorovsky committed Aug 1, 2023
1 parent 8126103 commit 54ce687
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 85 deletions.
2 changes: 2 additions & 0 deletions .cargo-rdme.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
workspace-project = "light-poseidon"
heading-base-level = 1
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
args: -- -D warnings

- name: Check README
uses: actions-rs/cargo@v1
with:
command: xtask
args: generate-readme --check
run: |
cargo install cargo-rdme
cargo rdme --check
34 changes: 12 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

# light-poseidon

<!-- cargo-rdme start -->

**light-poseidon** is a [Poseidon](https://eprint.iacr.org/2019/458) hash
implementation in Rust created for [Light Protocol](https://www.lightprotocol.com/).

Expand All @@ -25,26 +27,23 @@ The parameters can be generated with:
cargo xtask generate-poseidon-parameters
````

# Output type
## Output type

[`Poseidon`](crate::Poseidon) type implements two traits which serve the purpose
[`Poseidon`](https://docs.rs/light-poseidon/latest/light_poseidon/struct.Poseidon.html) type implements two traits which serve the purpose
of returning the calculated hash in different representations:

* [`PoseidonBytesHasher`](crate::PoseidonBytesHasher) with the
[`hash_bytes_be`](crate::PoseidonBytesHasher::hash_bytes_be) and
[`hash_bytes_le`](crate::PoseidonBytesHasher::hash_bytes_le) methods which
returns a byte array.
* [`PoseidonHasher`](crate::PoseidonHasher) with the
[`hash`](crate::PoseidonHasher::hash) method which returns
* [`PoseidonBytesHasher`](https://docs.rs/light-poseidon/latest/light_poseidon/trait.PoseidonBytesHasher.html) with the
`hash_bytes_be` and `hash_bytes_le` methods which returns a byte array.
* [`PoseidonHasher`](https://docs.rs/light-poseidon/latest/light_poseidon/trait.PoseidonHasher.html) with the `hash` method which returns
[`ark_ff::PrimeField`](ark_ff::PrimeField). Might be useful if you want
to immediately process the result with an another library which works with
[`ark_ff::PrimeField`](ark_ff::PrimeField) types.

# Examples
## Examples

Example with two simple big-endian byte inputs (converted to field elements)
and BN254-based parameters provided by the library, with
[`PoseidonBytesHasher`](crate::PoseidonHasher) trait and a byte array
[`PoseidonBytesHasher`](https://docs.rs/light-poseidon/latest/light_poseidon/trait.PoseidonHasher.html) trait and a byte array
result:

```rust
Expand All @@ -64,7 +63,7 @@ println!("{:?}", hash);
// ]
```
With [`PoseidonHasher`][crate::PoseidonHasher] trait and
With [`PoseidonHasher`](https://docs.rs/light-poseidon/latest/light_poseidon/trait.PoseidonHasher.html) trait and
[`ark_ff::PrimeField`](ark_ff::PrimeField) result:
```rust
Expand All @@ -91,7 +90,7 @@ but it was also inspired by the following ones:
* [circomlibjs](https://github.com/iden3/circomlibjs)
* [zero-knowledge-gadgets](https://github.com/webb-tools/zero-knowledge-gadgets)
### Performance
## Performance
This repository contains a benchmark measuring the performance of this
Poseidon implementation for given 1 - 12 random 32 bytes inputs.
Expand Down Expand Up @@ -141,13 +140,4 @@ poseidon_bn254_x5_12 time: [295.47 µs 305.80 µs 316.41 µs]
This library has been audited by [Veridise](https://veridise.com/). You can
read the audit report [here](https://github.com/Lightprotocol/light-poseidon/blob/main/assets/audit.pdf).
## License
Licensed under [Apache License, Version 2.0](LICENSE).
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.
<!-- cargo-rdme end -->
17 changes: 0 additions & 17 deletions README.tpl

This file was deleted.

38 changes: 0 additions & 38 deletions xtask/src/generate_readme.rs

This file was deleted.

4 changes: 0 additions & 4 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use clap::Parser;

mod generate_parameters;
mod generate_readme;

#[derive(Parser)]
pub struct XtaskOptions {
Expand All @@ -12,8 +11,6 @@ pub struct XtaskOptions {
#[derive(Parser)]
enum Command {
GeneratePoseidonParameters(generate_parameters::Options),
/// Generate the README.md file.
GenerateReadme(generate_readme::Options),
}

fn main() -> Result<(), anyhow::Error> {
Expand All @@ -23,7 +20,6 @@ fn main() -> Result<(), anyhow::Error> {
Command::GeneratePoseidonParameters(opts) => {
generate_parameters::generate_parameters(opts)?
}
Command::GenerateReadme(opts) => generate_readme::generate_readme(opts)?,
}

Ok(())
Expand Down

0 comments on commit 54ce687

Please sign in to comment.