func (s *OpencxAuctionServer) validateOrder(decryptedOrder *match.AuctionOrder, encryptedOrder *match.EncryptedAuctionOrder) (err error) {

	logging.Infof("Validating order by pubkey %x", decryptedOrder.Pubkey)

	if _, err = decryptedOrder.Price(); err != nil {
		err = fmt.Errorf("Orders with an indeterminable price are invalid: %s", err)
		return
	}

	if !decryptedOrder.IsBuySide() && !decryptedOrder.IsSellSide() {
		err = fmt.Errorf("Orders that aren't buy or sell side are invalid: %s", err)
		return
	}

	// We could use pub key hashes here but there might not be any reason for it
	var orderPublicKey *koblitz.PublicKey
	if orderPublicKey, err = koblitz.ParsePubKey(decryptedOrder.Pubkey[:], koblitz.S256()); err != nil {
		err = fmt.Errorf("Orders with a public key that cannot be parsed are invalid: %s", err)
		return
	}

	// e = h(asset)
	sha3 := sha3.New256()
	sha3.Write(decryptedOrder.SerializeSignable())
	e := sha3.Sum(nil)

	var recoveredPublickey *koblitz.PublicKey
	if recoveredPublickey, _, err = koblitz.RecoverCompact(koblitz.S256(), decryptedOrder.Signature, e); err != nil {
		err = fmt.Errorf("Orders whose signature cannot be verified with pubkey recovery are invalid: %s", err)
		return
	}

	if !recoveredPublickey.IsEqual(orderPublicKey) {
		err = fmt.Errorf("Recovered public key %x does not equal to pubkey %x in order", recoveredPublickey.SerializeCompressed(), orderPublicKey.SerializeCompressed())
		return
	}

	// TODO: figure out how to deal with auctionID
	// if !bytes.Equal(s.auctionID[:], decryptedOrder.AuctionID[:]) {
	// 	err = fmt.Errorf("Auction ID must equal current auction")
	// 	return
	// }

	return
}
// validateOrder is how the server checks that an order is valid, and checks out with its corresponding encrypted order
validateOrder is how the server checks that an order is valid, and checks out with its corresponding encrypted order
// validateOrder is how the server checks that an order is valid and checks out with its corresponding encrypted order
func (s *OpencxAuctionServer) validateOrder(decryptedOrder *match.AuctionOrder, encryptedOrder *match.EncryptedAuctionOrder) (err error) {
	logging.Infof("Validating order by pubkey %x", decryptedOrder.Pubkey)
	if _, err = decryptedOrder.Price(); err != nil {
		err = fmt.Errorf("Orders with an indeterminable price are invalid: %s", err)
		return
	}
	if !decryptedOrder.IsBuySide() && !decryptedOrder.IsSellSide() {
		err = fmt.Errorf("Orders that aren't buy or sell side are invalid: %s", err)
		return
	}
	var orderPublicKey *koblitz.PublicKey
	if orderPublicKey, err = koblitz.ParsePubKey(decryptedOrder.Pubkey[:], koblitz.S256()); err != nil {
		err = fmt.Errorf("Orders with a public key that cannot be parsed are invalid: %s", err)
		return
	}
	sha3 := sha3.New256()
	sha3.Write(decryptedOrder.SerializeSignable())
	e := sha3.Sum(nil)
	var recoveredPublickey *koblitz.PublicKey
	if recoveredPublickey, _, err = koblitz.RecoverCompact(koblitz.S256(), decryptedOrder.Signature, e); err != nil {
		err = fmt.Errorf("Orders whose signature cannot be verified with pubkey recovery are invalid: %s", err)
		return
	}
	if !recoveredPublickey.IsEqual(orderPublicKey) {
		err = fmt.Errorf("Recovered public key %x does not equal to pubkey %x in order", recoveredPublickey.SerializeCompressed(), orderPublicKey.SerializeCompressed())
		return
	}
	return
}
func ( s * OpencxAuctionServer ) validateOrder ( decryptedOrder * match . AuctionOrder , encryptedOrder * match . EncryptedAuctionOrder ) ( err error ) { logging . Infof ( " " , decryptedOrder . Pubkey ) if _ , err = decryptedOrder . Price ( ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if ! decryptedOrder . IsBuySide ( ) && ! decryptedOrder . IsSellSide ( ) { err = fmt . Errorf ( " " , err ) return } var orderPublicKey * koblitz . PublicKey if orderPublicKey , err = koblitz . ParsePubKey ( decryptedOrder . Pubkey [ : ] , koblitz . S256 ( ) ) ; err != nil { err = fmt . Errorf ( " " , err ) return } sha3 := sha3 . New256 ( ) sha3 . Write ( decryptedOrder . SerializeSignable ( ) ) e := sha3 . Sum ( nil ) var recoveredPublickey * koblitz . PublicKey if recoveredPublickey , _ , err = koblitz . RecoverCompact ( koblitz . S256 ( ) , decryptedOrder . Signature , e ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if ! recoveredPublickey . IsEqual ( orderPublicKey ) { err = fmt . Errorf ( " " , recoveredPublickey . SerializeCompressed ( ) , orderPublicKey . SerializeCompressed ( ) ) return } return }
validateOrder is how the server checks that an order is valid, and checks out with its corresponding encrypted order
validateOrder is how the server checks that an order is valid and checks out with its corresponding encrypted order
// We could use pub key hashes here but there might not be any reason for it // e = h(asset) // TODO: figure out how to deal with auctionID // if !bytes.Equal(s.auctionID[:], decryptedOrder.AuctionID[:]) { // 	err = fmt.Errorf("Auction ID must equal current auction") // 	return // }