Skip to content

Commit

Permalink
feat: add clman source generation config
Browse files Browse the repository at this point in the history
  • Loading branch information
keyvank committed Jun 5, 2020
1 parent 1ef41a7 commit d4dbe83
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ license = "MIT/Apache-2.0"
repository = "https://github.com/filecoin-project/ff-cl-gen"

[dependencies]
ff = { version = "0.2.0", package = "fff" }
rand_core = "0.5"
fff = { version = "0.2.0", features = ["derive"] }
itertools = { version = "0.8.0" }
num-bigint = "0.2"

Expand Down
6 changes: 6 additions & 0 deletions clman.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
version: 0.1.0
dyns:
ff.cl:
dockerfile: gen.Dockerfile
args: "$FIELD_NAME $FIELD_MODULUS"
31 changes: 31 additions & 0 deletions gen.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM rust:1.31
WORKDIR /usr/src/ff-cl-gen
RUN USER=root cargo init --bin
COPY ./rust-toolchain ./rust-toolchain
RUN cargo build --release
COPY ./Cargo.toml ./Cargo.toml
RUN cargo fetch
COPY ./src ./src
RUN cargo build --release
RUN apt-get update && apt-get install nano
RUN echo '\
extern crate rand_core; \n#\
[macro_use] \n\
extern crate fff; \n\
use fff::{Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr}; \n#\
[derive(PrimeField)] \n#\
[PrimeFieldModulus = "FIELD_MODULUS"] \n#\
[PrimeFieldGenerator = "7"] \n\
struct Fp(FpRepr); \n\
fn main() { \n\
println!("{}", ff_cl_gen::field::<Fp>("FIELD_NAME")); \n\
}' > ./src/main.rs

RUN echo '\
rm -rf ./target/release/ff-cl-gen > /dev/null 2>&1 \n\
sed -i "s/FIELD_NAME/$1/g" src/main.rs > /dev/null 2>&1 \n\
sed -i "s/FIELD_MODULUS/$2/g" src/main.rs > /dev/null 2>&1 \n\
cargo build --release > /dev/null 2>&1 \n\
./target/release/ff-cl-gen' > ./gen.sh

ENTRYPOINT ["sh", "./gen.sh"]
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ff::PrimeField;
use fff::PrimeField;
use itertools::*;
use num_bigint::BigUint;

Expand Down

0 comments on commit d4dbe83

Please sign in to comment.