Beispiel #1
0
// Checks that BlockSigs state correspond with coin.Blockchain state
// and that all signatures are valid.
func (self *BlockSigs) Verify(masterPublic cipher.PubKey,
	bc *coin.Blockchain) error {

	if len(bc.Blocks) != len(self.Sigs) {
		return errors.New("Missing signatures for blocks or vice versa")
	}
	blocks := uint64(len(bc.Blocks))
	// For now, block sigs must all be sequential and continuous
	if self.MaxSeq+1 != blocks {
		return errors.New("MaxSeq does not match blockchain size")
	}
	for i := uint64(0); i < self.MaxSeq; i++ {
		if _, ok := self.Sigs[i]; !ok {
			return errors.New("Blocksigs missing signature")
		}
	}

	for k, v := range self.Sigs {
		err := cipher.VerifySignature(masterPublic, v, bc.Blocks[k].HashHeader())
		if err != nil {
			return err
		}
	}
	return nil
}
Beispiel #2
0
// VerifySigs checks that BlockSigs state correspond with coin.Blockchain state
// and that all signatures are valid.
func (bc Blockchain) VerifySigs(pubKey cipher.PubKey, sigs *blockdb.BlockSigs) error {
	for i := uint64(0); i <= bc.Head().Seq(); i++ {
		b := bc.GetBlockInDepth(i)
		if b == nil {
			return fmt.Errorf("no block in depth %v", i)
		}
		// get sig
		sig, err := sigs.Get(b.HashHeader())
		if err != nil {
			return err
		}

		if err := cipher.VerifySignature(pubKey, sig, b.HashHeader()); err != nil {
			return err
		}
	}

	return nil
}
Beispiel #3
0
// Returns an error if the cipher.Sig is not valid for the coin.Block
func (self *Visor) verifySignedBlock(b *SignedBlock) error {
	return cipher.VerifySignature(self.Config.BlockchainPubkey, b.Sig,
		b.Block.HashHeader())
}
Beispiel #4
0
// Returns an error if the cipher.Sig is not valid for the coin.Block
func (self *Visor) verifySignedBlock(b *SignedBlock) error {
	return cipher.VerifySignature(self.Config.MasterKeys.Public, b.Sig,
		b.Block.HashHeader())
}
Beispiel #5
0
func (self *Blockchain) verifySignedBlock(b *SignedBlock) error {
	return cipher.VerifySignature(self.Genesis.PubKey, b.Sig,
		b.Block.HashHeader())
}