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

[refactor] #4339: refactor iroha_crypto, update API #4341

Merged
merged 10 commits into from
Mar 13, 2024

Conversation

0x009922
Copy link
Contributor

@0x009922 0x009922 commented Mar 4, 2024

Description

See linked issue.

Linked issue

Closes #4339

@0x009922 0x009922 added iroha2-dev The re-implementation of a BFT hyperledger in RUST api-changes Changes in the API for client libraries Refactor Improvement to overall code quality crypto labels Mar 4, 2024
@0x009922 0x009922 self-assigned this Mar 4, 2024
@coveralls
Copy link

coveralls commented Mar 4, 2024

Pull Request Test Coverage Report for Build 8257299862

Details

  • 215 of 244 (88.11%) changed or added relevant lines in 24 files are covered.
  • 4097 unchanged lines in 75 files lost coverage.
  • Overall coverage decreased (-0.2%) to 56.638%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cli/src/samples.rs 0 1 0.0%
tools/kagami/src/genesis.rs 0 1 0.0%
core/test_network/src/lib.rs 0 2 0.0%
tools/kagami/src/crypto.rs 0 6 0.0%
crypto/src/lib.rs 88 107 82.24%
Files with Coverage Reduction New Missed Lines %
primitives/src/conststr.rs 1 91.14%
ffi/derive/src/convert.rs 1 84.45%
primitives/src/lib.rs 1 0.0%
core/src/sumeragi/network_topology.rs 1 98.78%
data_model/derive/src/has_origin.rs 3 95.16%
config/src/kura.rs 3 80.0%
primitives/src/addr.rs 3 63.82%
schema/derive/src/lib.rs 5 83.25%
config/src/logger.rs 5 72.73%
tools/kagami/src/main.rs 5 0.0%
Totals Coverage Status
Change from base Build 7884695009: -0.2%
Covered Lines: 22134
Relevant Lines: 39080

💛 - Coveralls

crypto/src/signature/mod.rs Outdated Show resolved Hide resolved
crypto/src/lib.rs Outdated Show resolved Hide resolved
@0x009922
Copy link
Contributor Author

0x009922 commented Mar 5, 2024

Okay, so what's next:

  • rename to from_bytes anyway
  • change serialization to uppercase everywhere
  • create an issue with a bug of KeyGenConfiguration::from_private_key()

@0x009922
Copy link
Contributor Author

0x009922 commented Mar 5, 2024

I've updated KeyGenConfiguration using type-state-pattern, but it fails in checks and with ffi features enabled.

Will address it next. Probably, will try to simplify the builder yet remain it type-safe.

mversic
mversic previously approved these changes Mar 6, 2024
DCNick3
DCNick3 previously approved these changes Mar 6, 2024
@mversic mversic self-requested a review March 6, 2024 07:57
crypto/src/lib.rs Outdated Show resolved Hide resolved
crypto/src/lib.rs Outdated Show resolved Hide resolved
@0x009922 0x009922 dismissed stale reviews from DCNick3 and mversic via e79f617 March 6, 2024 09:31
@0x009922
Copy link
Contributor Author

0x009922 commented Mar 6, 2024

Updated how keys generation is configured. With some refactoring, managed to avoid unnecessary validation and panics in runtime thanks to types.

Renamed KeyGenConfiguration and KeyGenOption to KeyPairGenConfig and KeyPairGenOption respectively.

@0x009922 0x009922 requested a review from DCNick3 March 6, 2024 09:37
crypto/src/lib.rs Outdated Show resolved Hide resolved
crypto/src/lib.rs Outdated Show resolved Hide resolved
crypto/src/lib.rs Outdated Show resolved Hide resolved
crypto/src/lib.rs Outdated Show resolved Hide resolved
0x009922 added a commit to 0x009922/iroha-javascript that referenced this pull request Mar 8, 2024
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
mversic
mversic previously approved these changes Mar 11, 2024
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
There is also `iroha_swarm`, which still uses lowercase

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
- Rename `KeyPair::generate` to `KeyPair::random`
- Add `KeyPair::random_with_algorithm`
- Add `KeyPair::from_seed`
- Add `impl From<PrivateKey> for KeyPair`

Also:

- Rename `KeyPair::new` to `KeyPair::from_raw_parts`
  for consistency

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
- revert `from_raw_parts` to `new`
- rename `into_raw_parts` to `into_parts`
- remove `impl From<KeyPair> to (K, K)`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
@0x009922 0x009922 merged commit 7014f53 into hyperledger-iroha:iroha2-dev Mar 13, 2024
13 checks passed
@0x009922 0x009922 deleted the 4339-crypto-refactor branch March 13, 2024 09:30
0x009922 added a commit to hyperledger-iroha/iroha-javascript that referenced this pull request Mar 14, 2024
* [refactor]: update WASM API, wip

`cargo check --target wasm32-unknown-unknown` fails:
`getrandom` crate features are invalid

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [feat]: complete refactoring (upstream is WIP)

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: update upstream to hyperledger-iroha/iroha#4341

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: update crypto, finally

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

---------

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-changes Changes in the API for client libraries crypto iroha2-dev The re-implementation of a BFT hyperledger in RUST Refactor Improvement to overall code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants