Exemplo n.º 1
0
// Checks that BlockSigs state correspond with coin.Blockchain state
// and that all signatures are valid.
func (self *BlockSigs) Verify(masterPublic coin.PubKey, bc *coin.Blockchain) error {
	blocks := uint64(len(bc.Blocks))
	if blocks != uint64(len(self.Sigs)) {
		return errors.New("Missing signatures for blocks or vice versa")
	}

	// 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 := coin.VerifySignature(masterPublic, v, bc.Blocks[k].HashHeader())
		if err != nil {
			return err
		}
	}
	return nil
}
Exemplo n.º 2
0
// Returns an error if the coin.Sig is not valid for the coin.Block
func (self *Visor) verifySignedBlock(b *SignedBlock) error {
	return coin.VerifySignature(self.Config.MasterKeys.Public, b.Sig,
		b.Block.HashHeader())
}
Exemplo n.º 3
0
func (self *Blockchain) verifySignedBlock(b *SignedBlock) error {
	return coin.VerifySignature(self.Genesis.PubKey, b.Sig,
		b.Block.HashHeader())
}