-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: extend the maximum number of characters that can be decoded to 200 characters #159
Conversation
Codecov Report
@@ Coverage Diff @@
## feat/bech32plus #159 +/- ##
===================================================
+ Coverage 62.52% 62.69% +0.16%
===================================================
Files 283 284 +1
Lines 26475 26617 +142
===================================================
+ Hits 16554 16688 +134
- Misses 8576 8580 +4
- Partials 1345 1349 +4
|
libs/bech32/bech32plus.go
Outdated
// Decode decodes a bech32 encoded string, returning the human-readable | ||
// part and the data part excluding the checksum. | ||
func Decode(bech string) (string, []byte, error) { | ||
// The maximum allowed length for a bech32 string is 90. It must also |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bech32 string is 90
Should update 90
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I will fix.
msg := bytes.NewBuffer(pk.SignKey.Bytes()) | ||
msg.Write(pk.VrfKey.Bytes()) | ||
return msg.Bytes() | ||
bz, err := cdc.MarshalBinaryBare(pk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using bytes.NewBuffer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: https://github.com/line/tendermint/blob/develop/docs/architecture/adr-015-crypto-encoding.md
Context
We must standardize our method for encoding public keys and signatures on chain. Currently we amino encode the public keys and signatures. The reason we are using amino here is primarily due to ease of support in parsing for other languages. We don't need its upgradability properties in cryptosystems, as a change in the crypto that requires adapting the encoding, likely warrants being deemed a new cryptosystem. (I.e. using new public parameters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. It was used to identify it as a unique value as a [] byte array inside tendermint. However, according to the specifications of tendermint, it seems correct to use amino encoding.
@@ -67,7 +87,7 @@ func (sk PrivKeyComposite) Identity() crypto.PrivKey { | |||
} | |||
|
|||
func (sk PrivKeyComposite) Bytes() []byte { | |||
return sk.Identity().Bytes() | |||
return cdc.MustMarshalBinaryBare(sk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using sk.Identity().Bytes()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I answered above, the reason is the same as PubKeyComposite
.
@@ -0,0 +1,255 @@ | |||
// Copyright (c) 2017 The btcsuite developers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add our copylight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. No. I will delete it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, don't we need copyright? Really?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ISC license is a non-copyleft type license. In this case, the copyright is not inherited, so the copyright notice may or may not be present, but just in case, it is attached as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should. The above was a bit inaccurate. Sorry. It seems correct to describe the license for LINE. Since the license name has not been decided now, I treated it as TODO
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, the non-copyleft license means that license inheritance doesn't apply. The "license inheritance" means that the source code to be copied must be under the identical license. However, license inheritance and copyright notice obligations are different concepts.
Therefore, we don't need to inherit the ISC license, but we do need to leave the copyright notice according to the ISC license.
@@ -0,0 +1,72 @@ | |||
// Copyright (c) 2017 The btcsuite developers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add our copylight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should. It seems correct to describe the license for LINE. Since the license name has not been decided now, I treated it as TODO.
@@ -0,0 +1,49 @@ | |||
// Copyright (c) 2017 The btcsuite developers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add our copylight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should. It seems correct to describe the license for LINE. Since the license name has not been decided now, I treated it as TODO.
…btcsuite/btcutil/bech32/bech32.go
crypto/encoding/amino/encode_test.go
Outdated
@@ -155,6 +168,7 @@ func TestPubkeyAminoName(t *testing.T) { | |||
{ed25519.PubKeyEd25519{}, ed25519.PubKeyAminoName, true}, | |||
{sr25519.PubKeySr25519{}, sr25519.PubKeyAminoName, true}, | |||
{secp256k1.PubKeySecp256k1{}, secp256k1.PubKeyAminoName, true}, | |||
{composite.PubKeyComposite{}, composite.PubKeyAminoName, true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add bls
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I will add bls
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed. PTAL.
assert.NotNil(t, genDoc.ConsensusParams, "expected consensus params to be filled in") | ||
|
||
// check validator's address is filled | ||
assert.NotNil(t, genDoc.Validators[0].Address, "expected validator's address to be filled in") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you check the composite fields? Is it enough to check Address
since you add this test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is. The address is generated from the pubkey. Therefore, the address check includes the pubkey check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that we should check the type whether composite or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I added the test case whether composite or not.
crypto/composite/composite_test.go
Outdated
@@ -253,7 +254,7 @@ func TestEnvironmentalCompatibility(t *testing.T) { | |||
// compare addresses to assumed value | |||
compositePrivKey := composite.NewPrivKeyComposite(blsPrivKey, ed25519PrivKey) | |||
compositePubKey := compositePrivKey.PubKey() | |||
address, err := hex.DecodeString("7A68265205CB115AE35A13515C423F1721E87BB4") | |||
address, err := hex.DecodeString(strings.ToUpper("72dd758835404175940f698cf3ddc29dd0d04afa")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: No need to do ToUpper
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. That's right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed. PTAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -0,0 +1,255 @@ | |||
// Copyright (c) 2017 The btcsuite developers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, the non-copyleft license means that license inheritance doesn't apply. The "license inheritance" means that the source code to be copied must be under the identical license. However, license inheritance and copyright notice obligations are different concepts.
Therefore, we don't need to inherit the ISC license, but we do need to leave the copyright notice according to the ISC license.
feat: extend the maximum number of characters that can be decoded to 200 characters (#159)
Closes: Finschia/finschia-sdk#47
Description
For contributor use: