当前位置: 首页>>代码示例>>Golang>>正文


Golang utils.CheckSign函数代码示例

本文整理汇总了Golang中github.com/c-darwin/dcoin-go/packages/utils.CheckSign函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckSign函数的具体用法?Golang CheckSign怎么用?Golang CheckSign使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CheckSign函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: AdminAddCurrencyFront

func (p *Parser) AdminAddCurrencyFront() error {

	err := p.generalCheckAdmin()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"currency_name": "currency_name", "currency_full_name": "currency_full_name", "max_promised_amount": "int", "max_other_currencies": "int"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}

	// проверим, нет ли уже такой валюты
	name, err := p.Single("SELECT name FROM currency WHERE name  =  ?", p.TxMaps.String["currency_name"]).String()
	if err != nil {
		return p.ErrInfo(err)
	}
	if len(name) > 0 {
		return p.ErrInfo("exists currency_name")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["currency_name"], p.TxMap["currency_full_name"], p.TxMap["max_promised_amount"], p.TxMap["max_other_currencies"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:33,代码来源:admin_add_currency.go

示例2: DelCreditFront

func (p *Parser) DelCreditFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"credit_id": "bigint"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}

	// явлется данный юзер кредитором
	id, err := p.Single("SELECT id FROM credits WHERE id  =  ? AND to_user_id  =  ? AND del_block_id  =  0", p.TxMaps.Int64["credit_id"], p.TxUserID).Int64()
	if err != nil {
		return p.ErrInfo(err)
	}
	if id == 0 {
		return p.ErrInfo("not a creditor")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["credit_id"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:33,代码来源:del_credit.go

示例3: AdminBlogFront

func (p *Parser) AdminBlogFront() error {

	err := p.generalCheckAdmin()
	if err != nil {
		return p.ErrInfo(err)
	}

	if len(p.TxMaps.String["title"]) > 255 {
		return p.ErrInfo("len title>255")
	}
	if len(p.TxMaps.String["message"]) > 1048576 {
		return p.ErrInfo("len message>1048576")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["lng"], p.TxMap["title"], p.TxMap["message"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:25,代码来源:admin_blog.go

示例4: AdminAnswerFront

func (p *Parser) AdminAnswerFront() error {

	err := p.generalCheckAdmin()
	if err != nil {
		return p.ErrInfo(err)
	}

	if len(p.TxMaps.Bytes["encrypted_message"]) > 20480 {
		return p.ErrInfo("len encrypted_message>20480")
	}
	verifyData := map[string]string{"to_user_id": "user_id"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["to_user_id"], p.TxMap["encrypted_message"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:27,代码来源:admin_answer.go

示例5: AdminNewVersionFront

func (p *Parser) AdminNewVersionFront() error {

	err := p.generalCheckAdmin()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"version": "version", "soft_type": "soft_type"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}

	version, err := p.Single("SELECT version FROM new_version WHERE version  =  ?", p.TxMap["version"]).String()
	if err != nil {
		return p.ErrInfo(err)
	}
	if len(version) > 0 {
		return p.ErrInfo("exists version")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["soft_type"], p.TxMap["version"], utils.Sha256(p.TxMap["file"]), p.TxMap["format"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}
	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:31,代码来源:admin_new_version.go

示例6: ChangeSellerHoldBackFront

func (p *Parser) ChangeSellerHoldBackFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"arbitration_days_refund": "smallint", "hold_back_pct": "pct"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}

	if p.TxMaps.Money["hold_back_pct"] < 0.01 || p.TxMaps.Money["hold_back_pct"] > 100 {
		return p.ErrInfo("incorrect hold_back_pct")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["arbitration_days_refund"], p.TxMap["hold_back_pct"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(consts.LIMIT_CHANGE_SELLER_HOLD_BACK, "change_seller_hold_back", consts.LIMIT_CHANGE_SELLER_HOLD_BACK_PERIOD)
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:32,代码来源:change_seller_hold_back.go

示例7: ChangePrimaryKeyFront

func (p *Parser) ChangePrimaryKeyFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	if !utils.CheckInputData(p.newPublicKeysHex[0], "public_key") {
		return p.ErrInfo("public_key")
	}
	if len(p.newPublicKeysHex[1]) > 0 && !utils.CheckInputData(p.newPublicKeysHex[1], "public_key") {
		return p.ErrInfo("public_key 1")
	}
	if len(p.newPublicKeysHex[2]) > 0 && !utils.CheckInputData(p.newPublicKeysHex[2], "public_key") {
		return p.ErrInfo("public_key 2")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.newPublicKeysHex[0], p.newPublicKeysHex[1], p.newPublicKeysHex[2])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(p.Variables.Int64["limit_primary_key"], "primary_key", p.Variables.Int64["limit_primary_key_period"])
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:32,代码来源:change_primary_key.go

示例8: AdminNewVersionAlertFront

func (p *Parser) AdminNewVersionAlertFront() error {

	err := p.generalCheckAdmin()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"version": "version", "soft_type": "soft_type"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}

	alert, err := p.Single("SELECT alert FROM new_version WHERE version  =  ?", p.TxMaps.String["version"]).Int64()
	if err != nil {
		return p.ErrInfo(err)
	}
	if alert == 1 {
		return p.ErrInfo("alert == 1")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["soft_type"], p.TxMap["version"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:32,代码来源:admin_new_version_alert.go

示例9: ChangeCaFront

func (p *Parser) ChangeCaFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	if !utils.CheckInputData(p.TxMaps.String["ca1"], "ca_url") && p.TxMaps.String["ca1"] != "0" {
		return fmt.Errorf("incorrect ca1")
	}
	if !utils.CheckInputData(p.TxMaps.String["ca2"], "ca_url") && p.TxMaps.String["ca2"] != "0" {
		return fmt.Errorf("incorrect ca2")
	}
	if !utils.CheckInputData(p.TxMaps.String["ca3"], "ca_url") && p.TxMaps.String["ca3"] != "0" {
		return fmt.Errorf("incorrect ca3")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["ca1"], p.TxMap["ca2"], p.TxMap["ca3"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(consts.LIMIT_CHANGE_CA, "change_ca", consts.LIMIT_CHANGE_CA_PERIOD)
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:32,代码来源:change_ca.go

示例10: UserAvatarFront

func (p *Parser) UserAvatarFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"name": "user_name"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !utils.CheckInputData(p.TxMaps.String["avatar"], "img_url") && p.TxMaps.String["avatar"] != "0" {
		return fmt.Errorf("incorrect avatar")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["name"], p.TxMap["avatar"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(consts.LIMIT_USER_AVATAR, "user_avatar", consts.LIMIT_USER_AVATAR_PERIOD)
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:31,代码来源:user_avatar.go

示例11: ChangeKeyActiveFront

func (p *Parser) ChangeKeyActiveFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}
	if len(p.TxMaps.Bytes["secret"]) > 2048 {
		return p.ErrInfo("len secret > 2048")
	}

	// проверим, чтобы не было повторных смен
	changeKey, err := p.Single("SELECT change_key FROM users WHERE user_id  =  ?", p.TxUserID).Int64()
	if err != nil {
		return p.ErrInfo(err)
	}
	if changeKey == p.TxMaps.Int64["active"] {
		return p.ErrInfo("active")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMaps.String["secret_hex"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(consts.LIMIT_CHANGE_KEY_ACTIVE, "change_key_active", consts.LIMIT_CHANGE_KEY_ACTIVE_PERIOD)
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:34,代码来源:change_key_active.go

示例12: DelAutoPaymentFront

func (p *Parser) DelAutoPaymentFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"auto_payment_id": "int"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}
	// проверим, есть ли такой автоплатеж, принадлежащий нашем юзеру
	autoPayment, err := p.Single("SELECT id FROM auto_payments WHERE id  =  ? and sender = ?", p.TxMaps.Int64["project_id"], p.TxUserID).Int64()
	if err != nil {
		return p.ErrInfo(err)
	}
	if autoPayment == 0 {
		return p.ErrInfo("incorrect auto_payment_id")
	}
	forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["auto_payment_id"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}
	return nil
}
开发者ID:andreinechaev,项目名称:dcoin-go,代码行数:30,代码来源:del_auto_payment.go

示例13: ChangeKeyCloseFront

func (p *Parser) ChangeKeyCloseFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	// проверим, не стоит ли уже close
	changeKeyClose, err := p.Single("SELECT change_key_close FROM users WHERE user_id  =  ?", p.TxUserID).Int64()
	if err != nil {
		return p.ErrInfo(err)
	}
	if changeKeyClose > 0 {
		return p.ErrInfo("change_key_close=1")
	}

	forSign := fmt.Sprintf("%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:27,代码来源:change_key_close.go

示例14: MessageToAdminFront

func (p *Parser) MessageToAdminFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	// в бинарном виде проверить можем только размер
	if len(p.TxMaps.Bytes["encrypted_message"]) > 20480 || len(p.TxMaps.Bytes["encrypted_message"]) == 0 {
		return p.ErrInfo("encrypted_message len")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["encrypted_message"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(p.Variables.Int64["limit_message_to_admin"], "message_to_admin", p.Variables.Int64["limit_message_to_admin_period"])
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:27,代码来源:message_to_admin.go

示例15: MoneyBackFront

func (p *Parser) MoneyBackFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"order_id": "bigint", "amount": "amount"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}

	var txTime int64
	if p.BlockData != nil {
		txTime = p.BlockData.Time
	} else {
		txTime = time.Now().Unix() - 30 // просто на всякий случай небольшой запас
	}

	// проверим корректность ордера. тр-ия может быть как от продавца, так и от арбитра
	orderId, err := p.Single(`
				SELECT id
				FROM orders
				WHERE id = ? AND
							 status = 'refund' AND
							 (
									(
										 (arbitrator0 = ? OR arbitrator1 = ? OR arbitrator2 = ? OR arbitrator3 = ? OR arbitrator4 = ?) AND
										 refund = 0 AND
										  (amount - voluntary_refund - ?) >= 0 AND
										 end_time >= ?
									)
									OR (
										 seller = ? AND
										 voluntary_refund = 0 AND
										  (amount - refund - ?) >= 0 AND
										 end_time >= ?
									)
							)
				LIMIT 1
	`, p.TxMaps.Int64["order_id"], p.TxUserID, p.TxUserID, p.TxUserID, p.TxUserID, p.TxUserID, string(p.TxMap["amount"]), txTime, p.TxUserID, string(p.TxMap["amount"]), txTime).Int64()
	if err != nil {
		return p.ErrInfo(err)
	}
	if orderId == 0 {
		return p.ErrInfo("orderId==0")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["order_id"], p.TxMap["amount"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:60,代码来源:money_back.go


注:本文中的github.com/c-darwin/dcoin-go/packages/utils.CheckSign函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。