Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make verify-bls-signatures no_std compatible #137

Merged
merged 3 commits into from
Jun 8, 2023
Merged

Make verify-bls-signatures no_std compatible #137

merged 3 commits into from
Jun 8, 2023

Conversation

jimmychu0807
Copy link
Contributor

  • Fixed a warning and compile
  • Adding verify-bls-signatures in utils
  • Replace Rand lib with getrandom to make it no_std compatible

- Adding verify-bls-signatures in utils
- Replace Rand lib with getrandom to make it no_std compatible
@jimmychu0807
Copy link
Contributor Author

@ytqaljn In this PR, I added verify-bls-signatures in utils. What I have mostly changed are commented in the code.

Comment on lines +12 to +20
# rand = { version = "0.8.5", default-features = false, features = ["getrandom"] }

# Check references:
# - https://docs.rs/getrandom/latest/getrandom/index.html
# - https://rust-random.github.io/book/crates.html
# - https://github.com/rust-random/getrandom/pull/109 // This one explains why "custom" feature
# is added, and we will need to call `register_custom_getrandom` in future.
# - https://docs.rs/getrandom/latest/getrandom/index.html#custom-implementations
getrandom = { version = "0.2.10", default-features = false, features = ["custom"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key change, using getrandom lib instead of rand lib. Compare it with dfinity original line:
https://github.com/dfinity/verify-bls-signatures/blob/master/Cargo.toml#L12

I added references on the above on using getrandom and caveat of it. We may need to register our own randomize() function in future.

Comment on lines +186 to +192
// let mut rng = rand::thread_rng();
loop {
let mut buf = [0u8; 32];
// rng.fill_bytes(&mut buf);
// note: Handle the `Result` below
getrandom::getrandom(&mut buf);
let s: Option<Scalar> = Scalar::from_bytes(&buf).into();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, instead of using rand, we use getrandom

@ytqaljn ytqaljn merged commit 5fc90a6 into CESSProject:sprint7-file-restoral Jun 8, 2023
@jimmychu0807 jimmychu0807 deleted the jc/sprint7-fire-restoral branch June 8, 2023 07:09
AstaFrode pushed a commit that referenced this pull request Jun 9, 2023
* fix: renewal space unfreeze

* feat: add some root extrisic

* feat: add some root function for test

* style: 0.5.4 add new field

* style: for distinguish chain

* feat: some root function for test

* feat: for test

* test: migration test

* fix: fix random bug

* fix: index from 1 start

* fix: random seed

* fix: random seed

* config: string limit 50000 -> 60000

* feat: batch delete files

* style: clear warning

* merge: frame-upgrade

* fix: fix merge bug

* refactor: add storage-handler pallet

* fix: fix recursing

* refactor: file-bank pallet adapt

* refactor: adapt storage handle

* refactor: rename file-map -> tee-worker

* refactor: rename file-map -> tee-worker

* fix: bug

* refactor: segment-book -> audit

* feat: upload_deal

* feat: upload_deal

* feat: upload_deal

* feat: upload_deal

* feat: upload deal

* feat: tranfser_report

* feat: time task deal_reassign_miner

* feat: unlock space for miner

* feat: calculate time task

* feat: delete file

* style: add Event

* style: fix warning

* refactor: idle space and service space change when segment add or delete

* feat: some func for test

* style: framework optimization

* fix: update FragmentCount const

* fix: fragment repeat causing BoundedVecError

* refactor: tuple to struct for go-substrate-sdk

* fix: update lock space, miner and user

* feat: add two new package

* feat: tee register

* feat: add report verify

* feat: generate challeng(40%)

* tests: ed25519 verify sig

* feat: generate challenge

* feat: submit prove

* feat: challenge clear

* feat: miner reward

* feat: clear and prove punish

* feat: three punish

* feat: lock miner

* feat: miner exit

* feat: filter for lock miner

* feat: update increase_collateral for debt

* feat: force miner exit

* feat: use force exit miner

* feat: clear expire file

* feat: delete file

* fix: transfer file  delete file

* feat: test rsa verify

* style: fix warning

* style: peer id types update

* feat: unlock offchain

* feat: add punish tee worker

* fix: challenge select miner when miner number < 10

* fix: fix challengesnapshot bug

* fix: miner exit bug

* style: add withdraw event

* style: update type

* test: add some test function

* test: add update_peer_id and exit

* test: purchase in mib units

* feat: random 0.046 chunks and random random number

* feat: add new filed

* fix: fix bug in reassigning validation tasks

* style: delete methods that are no longer in use

* feat: add methods for deleting fillers

* style: some related modifications made for testing purposes

* fix: miner exit prep error

* feat: restoral file

* fix: fix compile error

* fix: fix random select miner

* style: add restoral event

* refactor: optimize space expiration functionality

* test: some for test function

* feat: add stake_score in validator election (#125)

* feat: add stake_score in election

* fix: merge conflics

* fix: paritytech/substrate#13804

* test: test for bls

* style: merge

* test: test bls

* feat: restoral order storage

* feat: restoral order storage key

* test: update data for test

* fix: fix space expire bug

* fix: fix upload file user hold slice list

* fix: fix random select miner

* test: for test add some function

* Make verify-bls-signatures no_std compatible (#137)

* - Fixed a warning and compile
- Adding verify-bls-signatures in utils
- Replace Rand lib with getrandom to make it no_std compatible

* uncomment BLS and using dummy rand

* Using getrandom custom

* fix: cancel schedule mission

* fix: file upload update UserBucketList

* style: streamline code

* fix: space expired user bucket list kill

* Update README.md

---------

Co-authored-by: ytqaljn <2716693942@qq.com>
Co-authored-by: Shaka Lavigne <shakawwq@gmail.com>
Co-authored-by: Jimmy Chu <jimmychu0807@gmail.com>
Co-authored-by: Dean Clark <32699199+thirteenggh@users.noreply.github.com>
AstaFrode added a commit that referenced this pull request Jun 13, 2023
* fix: renewal space unfreeze

* feat: add some root extrisic

* feat: add some root function for test

* style: 0.5.4 add new field

* style: for distinguish chain

* feat: some root function for test

* feat: for test

* test: migration test

* fix: fix random bug

* fix: index from 1 start

* fix: random seed

* fix: random seed

* config: string limit 50000 -> 60000

* feat: batch delete files

* style: clear warning

* merge: frame-upgrade

* fix: fix merge bug

* refactor: add storage-handler pallet

* fix: fix recursing

* refactor: file-bank pallet adapt

* refactor: adapt storage handle

* refactor: rename file-map -> tee-worker

* refactor: rename file-map -> tee-worker

* fix: bug

* refactor: segment-book -> audit

* feat: upload_deal

* feat: upload_deal

* feat: upload_deal

* feat: upload_deal

* feat: upload deal

* feat: tranfser_report

* feat: time task deal_reassign_miner

* feat: unlock space for miner

* feat: calculate time task

* feat: delete file

* style: add Event

* style: fix warning

* refactor: idle space and service space change when segment add or delete

* feat: some func for test

* style: framework optimization

* fix: update FragmentCount const

* fix: fragment repeat causing BoundedVecError

* refactor: tuple to struct for go-substrate-sdk

* fix: update lock space, miner and user

* feat: add two new package

* feat: tee register

* feat: add report verify

* feat: generate challeng(40%)

* tests: ed25519 verify sig

* feat: generate challenge

* feat: submit prove

* feat: challenge clear

* feat: miner reward

* feat: clear and prove punish

* feat: three punish

* feat: lock miner

* feat: miner exit

* feat: filter for lock miner

* feat: update increase_collateral for debt

* feat: force miner exit

* feat: use force exit miner

* feat: clear expire file

* feat: delete file

* fix: transfer file  delete file

* feat: test rsa verify

* style: fix warning

* style: peer id types update

* feat: unlock offchain

* feat: add punish tee worker

* fix: challenge select miner when miner number < 10

* fix: fix challengesnapshot bug

* fix: miner exit bug

* style: add withdraw event

* style: update type

* test: add some test function

* test: add update_peer_id and exit

* test: purchase in mib units

* feat: random 0.046 chunks and random random number

* feat: add new filed

* fix: fix bug in reassigning validation tasks

* style: delete methods that are no longer in use

* feat: add methods for deleting fillers

* style: some related modifications made for testing purposes

* fix: miner exit prep error

* feat: restoral file

* fix: fix compile error

* fix: fix random select miner

* style: add restoral event

* refactor: optimize space expiration functionality

* test: some for test function

* feat: add stake_score in validator election (#125)

* feat: add stake_score in election

* fix: merge conflics

* fix: paritytech/substrate#13804

* test: test for bls

* style: merge

* test: test bls

* feat: restoral order storage

* feat: restoral order storage key

* test: update data for test

* fix: fix space expire bug

* fix: fix upload file user hold slice list

* fix: fix random select miner

* test: for test add some function

* Make verify-bls-signatures no_std compatible (#137)

* - Fixed a warning and compile
- Adding verify-bls-signatures in utils
- Replace Rand lib with getrandom to make it no_std compatible

* uncomment BLS and using dummy rand

* Using getrandom custom

* fix: cancel schedule mission

* fix: file upload update UserBucketList

* style: streamline code

* fix: space expired user bucket list kill

---------

Co-authored-by: ytqaljn <2716693942@qq.com>
Co-authored-by: Shaka Lavigne <shakawwq@gmail.com>
Co-authored-by: Jimmy Chu <jimmychu0807@gmail.com>
Co-authored-by: Dean Clark <32699199+thirteenggh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants