changing from string to BlsSignature type

pull/1946/head
Ganesha Upadhyaya 5 years ago
parent 19b5083ee7
commit b6ad632dc1
  1. 7
      shard/shard_state.go
  2. 4
      staking/types/messages.go
  3. 6
      staking/types/validator.go

@ -21,7 +21,10 @@ var (
)
// PublicKeySizeInBytes ..
const PublicKeySizeInBytes = 48
const (
PublicKeySizeInBytes = 48
BlsSignatureSizeInBytes = 96
)
// State is the collection of all committees
type State struct {
@ -32,6 +35,8 @@ type State struct {
// BlsPublicKey defines the bls public key
type BlsPublicKey [PublicKeySizeInBytes]byte
type BlsSignature [BlsSignatureSizeInBytes]byte
// Slot represents node id (BLS address)
type Slot struct {
EcdsaAddress common.Address `json:"ecdsa-address"`

@ -60,7 +60,7 @@ type CreateValidator struct {
MinSelfDelegation *big.Int `json:"min_self_delegation" yaml:"min_self_delegation"`
MaxTotalDelegation *big.Int `json:"max_total_delegation" yaml:"max_total_delegation"`
SlotPubKeys []shard.BlsPublicKey `json:"slot_pub_keys" yaml:"slot_pub_keys"`
PubKeySigs []string `json:"pub_key_sigs" yarml:"pub_key_sigs"`
PubKeySigs []shard.BlsSignature `json:"pub_key_sigs" yarml:"pub_key_sigs"`
Amount *big.Int `json:"amount" yaml:"amount"`
}
@ -73,7 +73,7 @@ type EditValidator struct {
MaxTotalDelegation *big.Int `json:"max_total_delegation" yaml:"max_total_delegation" rlp:"nil"`
SlotKeyToRemove *shard.BlsPublicKey `json:"slot_key_to_remove" yaml:"slot_key_to_remove" rlp:"nil"`
SlotKeyToAdd *shard.BlsPublicKey `json:"slot_key_to_add" yaml:"slot_key_to_add" rlp:"nil"`
AddKeySig string `json:"add_key_sig" yaml:"add_key_sig" rlp:"nil"`
AddKeySig shard.BlsSignature `json:"add_key_sig" yaml:"add_key_sig" rlp:"nil"`
}
// Delegate - type for delegating to a validator

@ -229,7 +229,7 @@ func (v *Validator) GetCommissionRate() numeric.Dec { return v.Commission.Rate }
// GetMinSelfDelegation returns the minimum amount the validator must stake
func (v *Validator) GetMinSelfDelegation() *big.Int { return v.MinSelfDelegation }
func verifyBLSKeys(pubKeys []shard.BlsPublicKey, pubKeySigs []string) error {
func verifyBLSKeys(pubKeys []shard.BlsPublicKey, pubKeySigs []shard.BlsSignature) error {
if len(pubKeys) != len(pubKeySigs) {
return errBLSKeysNotMatchSigs
}
@ -243,7 +243,7 @@ func verifyBLSKeys(pubKeys []shard.BlsPublicKey, pubKeySigs []string) error {
return nil
}
func verifyBLSKey(pubKey shard.BlsPublicKey, pubKeySig string) error {
func verifyBLSKey(pubKey shard.BlsPublicKey, pubKeySig shard.BlsSignature) error {
if len(pubKeySig) == 0 {
return errBLSKeysNotMatchSigs
}
@ -254,7 +254,7 @@ func verifyBLSKey(pubKey shard.BlsPublicKey, pubKeySig string) error {
}
msgSig := bls.Sign{}
if err := msgSig.DeserializeHexStr(pubKeySig); err != nil {
if err := msgSig.Deserialize(pubKeySig[:]); err != nil {
return err
}

Loading…
Cancel
Save