Commit 08bc3a52 authored by 董子豪's avatar 董子豪

rust-proofs-api

parent b5f12d28
version: 2.1
jobs:
ensure_groth_parameters_and_keys_linux:
docker:
- image: filecoin/rust:latest
working_directory: /mnt/crate
resource_class: 2xlarge+
steps:
- configure_environment_variables
- checkout
- ensure_filecoin_parameters
cargo_fetch:
docker:
- image: filecoin/rust:latest
working_directory: /mnt/crate
resource_class: 2xlarge+
steps:
- configure_environment_variables
- checkout
- run:
name: Install requirements
command: apt-get install sudo -yqq
- run:
name: Install hwloc 2.3.0
command: |
cd /tmp
curl https://download.open-mpi.org/release/hwloc/v2.3/hwloc-2.3.0.tar.gz --location --output /tmp/hwloc-2.3.0.tar.gz
tar xzvf hwloc-2.3.0.tar.gz
cd hwloc-2.3.0
./configure
make
sudo make install
- run:
name: Calculate dependencies
command: cargo generate-lockfile
- restore_cache:
keys:
- cargo-v13-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
- run: rustup install $(cat rust-toolchain)
- run: rustup default $(cat rust-toolchain)
- run: rustup component add rustfmt-preview
- run: rustup component add clippy-preview
- run: cargo update
- run: cargo fetch
- run: rustc +$(cat rust-toolchain) --version
- persist_to_workspace:
root: "."
paths:
- Cargo.lock
- save_cache:
key: cargo-v13-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
paths:
- /root/.cargo
- /root/.rustup
test_pairing:
docker:
- image: filecoin/rust:latest
working_directory: /mnt/crate
resource_class: 2xlarge+
steps:
- configure_environment_variables
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v13-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
- run:
name: Test (pairing)
command: cargo +$(cat rust-toolchain) test --verbose
no_output_timeout: 15m
test_blst:
docker:
- image: filecoin/rust:latest
working_directory: /mnt/crate
resource_class: 2xlarge+
steps:
- configure_environment_variables
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v13-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
- run:
name: Test (blst)
command: cargo +$(cat rust-toolchain) test --verbose --no-default-features --features blst
no_output_timeout: 15m
rustfmt:
docker:
- image: filecoin/rust:latest
working_directory: /mnt/crate
resource_class: 2xlarge
steps:
- configure_environment_variables
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v13-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
- run:
name: Run cargo fmt
command: cargo fmt --all -- --check
clippy:
docker:
- image: filecoin/rust:latest
working_directory: /mnt/crate
resource_class: 2xlarge
steps:
- configure_environment_variables
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v13-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
- run:
name: Run cargo clippy
command: cargo clippy --workspace
test_darwin_pairing:
macos:
xcode: "10.0.0"
working_directory: ~/crate
resource_class: large
steps:
- configure_environment_variables
- checkout
- run:
name: Install other dependencies with Homebrew
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install hwloc
- run:
name: Install Rust
command: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
- run: rustup install $(cat rust-toolchain)
- run: rustup default $(cat rust-toolchain)
- run: cargo update
- run: cargo fetch
- run:
name: Test (Darwin, pairing)
command: cargo +$(cat rust-toolchain) test --release --verbose
no_output_timeout: 15m
test_darwin_blst:
macos:
xcode: "10.0.0"
working_directory: ~/crate
resource_class: large
steps:
- configure_environment_variables
- checkout
- run:
name: Install other dependencies with Homebrew
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install hwloc
- run:
name: Install Rust
command: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
- run: rustup install $(cat rust-toolchain)
- run: rustup default $(cat rust-toolchain)
- run: cargo update
- run: cargo fetch
- run:
name: Test (Darwin, blst)
command: cargo +$(cat rust-toolchain) test --release --verbose --no-default-features --features blst
no_output_timeout: 15m
commands:
configure_environment_variables:
steps:
- run:
name: Configure environment variables
command: |
echo 'export FIL_PROOFS_PARAMETER_CACHE="${HOME}/filecoin-proof-parameters/"' >> $BASH_ENV
echo 'export PATH="${HOME}/.cargo/bin:${PATH}"' >> $BASH_ENV
echo 'export RUST_LOG=info' >> $BASH_ENV
workflows:
version: 2.1
test_all:
jobs:
- cargo_fetch
- rustfmt:
requires:
- cargo_fetch
- clippy:
requires:
- cargo_fetch
- test_pairing:
requires:
- cargo_fetch
- test_blst:
requires:
- cargo_fetch
- test_darwin_pairing
- test_darwin_blst
# Changelog
All notable changes to filecoin-proofs-api will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://book.async.rs/overview/stability-guarantees.html).
## [Unreleased]
## [8.0.1] - 2021-06-09
- Updates for finalizing snarkpack support [#57](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/57)
## [8.0.0] - 2021-06-01
- Integrate Proof Aggregation API [#51](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/51)
## [7.0.0] - 2021-04-28
- Improve RAM usage during unseal [#56](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/56)
- Update rust-toolchain to 1.51.0 [#55](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/55)
## [6.1.0] - 2021-03-11
- Update docs and changelog for release [#53](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/53)
- Improve docs and update to latest Proofs [#52](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/52)
## [6.0.0] - 2020-12-01
- Add support for updated proofs api_versioning [#49](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/49)
## [5.4.1] - 2020-11-02
- Upgrade bellperson to required version [#48](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/48)
## [5.4.0] - 2020-11-02
- Upgrade filecoin_proofs dependency to v5.4.0
- Add new v1_1 RegisteredSealProofs to increment porep_id [#47](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/47)
## [5.3.0] - 2020-10-29
- Upgrade filecoin_proofs dependency to v5.3.0
- Integrate blst backend [#46](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/46)
- Create SECURITY.md [#45](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/45)
## [5.2.0] - 2020-09-28
- Update rustc to 1.46.0 [#44](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/44)
- Expose distributed PoSt API from proofs [#41](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/41)
## [5.1.1] - 2020-09-08
- Export storage proofs errors [#40](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/40)
- Replace unwrap usage with expect [#39](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/39)
## [5.1.0] - 2020-08-13
- Upgrade filecoin_proofs dependency to v5.1.1 [#38](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/38)
## [5.0.0] - 2020-08-11
- Upgrade filecoin_proofs dependency to v5.0.0 (v28 parameters) [#37](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/37)
## [4.0.4] - 2020-07-28
- Add fauxrep2 API [#35](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/35)
- Don't start a new dev version after a release [#34](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/34)
## [4.0.3] - 2020-07-06
- Use correct fauxrep shape type parameters per sector size [#32](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/32)
## [4.0.2] - 2020-07-01
- Upgrade filecoin_proofs dependency to v4.0.3
- Support fauxrep API [#30](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/30)
## [4.0.1] - 2020-06-25
- Upgrade filecoin_proofs dependency to v4.0.2
- Add some tests to ensure param and vk methods work [#28](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/28)
## [4.0.0] - 2020-06-15
- Upgrade filecoin_proofs dependency to v4.0.0
## [3.0.0] - 2020-06-08
- Upgrade filecoin_proofs dependency to v3.0.0
- Construct porep_id per RegisteredSealProof [#24](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/24)
- Update toolchain to use rust stable [#20](https://github.com/filecoin-project/rust-filecoin-proofs-api/pull/20)
## [2.0.0] - 2020-05-27
- Add public access to unseal_range method
- Upgrade filecoin_proofs dependency to v2.0.0
## [1.0.0] - 2020-05-19
- Initial stable release
[Unreleased]: https://github.com/filecoin-project/rust-filecoin-proofs-api/compare/v8.0.1...HEAD
[8.0.1]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v8.0.1
[8.0.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v8.0.0
[7.0.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v7.0.0
[6.1.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v6.1.0
[6.0.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v6.0.0
[5.4.1]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v5.4.1
[5.4.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v5.4.0
[5.3.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v5.3.0
[5.2.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v5.2.0
[5.1.1]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v5.1.1
[5.1.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v5.1.0
[5.0.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v5.0.0
[4.0.4]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v4.0.4
[4.0.3]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v4.0.3
[4.0.2]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v4.0.2
[4.0.1]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v4.0.1
[3.0.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v3.0.0
[2.0.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v2.0.0
[1.0.0]: https://github.com/filecoin-project/rust-filecoin-proofs-api/tree/v1.0.0
[package]
name = "filecoin-proofs-api"
version = "8.0.1"
description = "API to interact with the proofs system in Filecoin"
authors = ["dignifiedquire <me@dignifiedquire.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"
repository = "https://github.com/filecoin-project/rust-filecoin-proofs-api"
readme = "README.md"
[dependencies]
anyhow = "1.0.26"
bellperson = { version = "0.14.0", default-features = false }
bincode = "1.1.2"
serde = "1.0.104"
filecoin-proofs-v1 = { package = "filecoin-proofs", path = "../rust-fil-proofs/filecoin-proofs", version = "~8.0", default-features = false }
filecoin-hashers = { path = "../rust-fil-proofs/filecoin-hashers", version = "~3.0", default-features = false, features = ["poseidon", "sha256"] }
fr32 = { path = "../rust-fil-proofs/fr32", version = "~1.0", default-features = false }
storage-proofs-core = { path = "../rust-fil-proofs/storage-proofs-core", version = "~8.0", default-features = false }
[features]
default = ["pairing", "gpu"]
pairing = ["filecoin-proofs-v1/pairing", "bellperson/pairing", "storage-proofs-core/pairing", "fr32/pairing"]
blst = ["filecoin-proofs-v1/blst", "bellperson/blst", "storage-proofs-core/blst", "fr32/blst"]
gpu = ["filecoin-proofs-v1/gpu", "filecoin-hashers/gpu", "storage-proofs-core/gpu", "bellperson/gpu", "fr32/gpu"]
Copyright (c) 2018 Filecoin Project
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
\ No newline at end of file
# Filecoin Proofs API
This library is meant to be the official public API into the proofs library.
[![CircleCI](https://circleci.com/gh/filecoin-project/rust-filecoin-proofs-api/tree/master.svg?style=svg)](https://circleci.com/gh/filecoin-project/rust-filecoin-proofs-api/tree/master)
> The main API to interact with the proofs system in [Filecoin](https://filecoin.io).
## Default build options
The build options enabled by default are `pairing` and `gpu`. An alternative backend that can be used is `blst`. The `pairing` and `blst` options specify which bls12-381 pairing library to use..
## Running the tests
Running the tests with the default features can be done like this:
```
cargo test --release --all
```
Running with the `blst` and `gpu` features can be done like this:
```
cargo test --no-default-features --features blst,gpu --release --all
```
Running with `pairing` and without the `gpu` feature can be done like this:
```
cargo test --no-default-features --features pairing --release --all
```
## License
MIT or Apache 2.0
# Security Policy
## Reporting a Vulnerability
For reporting *critical* and *security* bugs, please consult our [Security Policy and Responsible Disclosure Program information](https://github.com/filecoin-project/community/blob/master/SECURITY.md)
## Reporting a non security bug
For non-critical bugs, please simply file a GitHub issue on this repo.
pre-release-commit-message = "chore({{crate_name}}): release {{version}}"
pro-release-commit-message = "chore({{crate_name}}): starting development cycle for {{next_version}}"
no-dev-version = true
#![deny(clippy::all, clippy::perf, clippy::correctness)]
#![allow(clippy::too_many_arguments)]
//requires nightly, or later stable version
//#![warn(clippy::unwrap_used)]
#![allow(clippy::upper_case_acronyms)]
pub mod post;
pub mod seal;
mod registry;
mod types;
pub use crate::registry::{RegisteredAggregationProof, RegisteredPoStProof, RegisteredSealProof};
pub use crate::types::{PrivateReplicaInfo, PublicReplicaInfo};
pub use filecoin_proofs_v1::types::{
AggregateSnarkProof, ChallengeSeed, Commitment, PaddedBytesAmount, PieceInfo, PoStType,
ProverId, Ticket, UnpaddedByteIndex, UnpaddedBytesAmount,
};
pub use filecoin_proofs_v1::{FallbackPoStSectorProof, SnarkProof, VanillaProof};
pub use fr32;
pub use storage_proofs_core::{
api_version::ApiVersion,
error::Error as StorageProofsError,
merkle::MerkleTreeTrait,
parameter_cache::{get_parameter_data, get_verifying_key_data},
sector::{OrderedSectorSet, SectorId},
util::NODE_SIZE,
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
use std::path::PathBuf;
use crate::{Commitment, RegisteredPoStProof};
// A byte serialized representation of a vanilla proof.
pub type VanillaProofBytes = Vec<u8>;
/// The minimal information required about a replica, in order to be able to generate
/// a PoSt over it.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct PrivateReplicaInfo {
/// The version of this replica.
pub(crate) registered_proof: RegisteredPoStProof,
/// The replica commitment.
pub(crate) comm_r: Commitment,
/// Contains sector-specific (e.g. merkle trees) assets
pub(crate) cache_dir: PathBuf,
/// Contains the replica.
pub(crate) replica_path: PathBuf,
}
impl PrivateReplicaInfo {
pub fn new(
registered_proof: RegisteredPoStProof,
comm_r: Commitment,
cache_dir: PathBuf,
replica_path: PathBuf,
) -> Self {
PrivateReplicaInfo {
registered_proof,
comm_r,
cache_dir,
replica_path,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct PublicReplicaInfo {
/// The version of this replica.
pub(crate) registered_proof: RegisteredPoStProof,
/// The replica commitment.
pub(crate) comm_r: Commitment,
}
impl PublicReplicaInfo {
pub fn new(registered_proof: RegisteredPoStProof, comm_r: Commitment) -> Self {
PublicReplicaInfo {
registered_proof,
comm_r,
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment