Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding sender signature details in block #144

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4d16a67
Adding sender signature details to block
maneeSHA-256 Apr 30, 2024
acd7f6a
Add function moveFile
Allen-Cherian Apr 29, 2024
f6fadf7
Add api and cmd : quorum-setup-check
Allen-Cherian Apr 29, 2024
5031ea3
Fix: flag quorumAddr not found [Add debug : WIP-Breaking]
Allen-Cherian Apr 30, 2024
a3c18d4
Fix: Quorom Status Check [Working]
Allen-Cherian Apr 30, 2024
b24fa9c
Update quorumlist to support Alternate quorum
Allen-Cherian Apr 30, 2024
17da864
Fix : Consensus request to selected quorums only- Alternate Quorums
Allen-Cherian Apr 30, 2024
5d9a84e
Fix : Consensus request to selected quorums only- Alternate Quorums W…
Allen-Cherian Apr 30, 2024
2bd283e
Fix: minor typo
Allen-Cherian May 2, 2024
0be3476
Add proper error messages
Allen-Cherian May 2, 2024
47cef17
Remove hardcoded quorum count
Allen-Cherian May 3, 2024
093646c
updated Readme
maneeSHA-256 May 6, 2024
babff64
changing variable and function names
maneeSHA-256 May 6, 2024
586b7a5
ping peer to get peer did type
maneeSHA-256 May 8, 2024
f0849cd
tested port-unavailability-fix on MacOs
maneeSHA-256 May 13, 2024
505f3ff
Merge branch 'development' into maneesha/sender-signature-in-block-wi…
maneeSHA-256 May 15, 2024
bd7b94c
change field name SignVersion to SignType
maneeSHA-256 May 15, 2024
d635854
feat: added API endpoint and CLI command to fetch a node's peer ID
arnabghose997 Apr 11, 2024
2d02d77
feat: added python tests for RBT transfer
arnabghose997 May 7, 2024
bb850f6
added func to get the build dir based on the target OS
arnabghose997 May 8, 2024
3d12ffa
added checks and instructions to support execution in windows os
arnabghose997 May 9, 2024
026b79a
feat: added test workflow
arnabghose997 May 13, 2024
9e2f1bd
added dockerfile for running tests in ubuntu-amd64 environment
arnabghose997 May 15, 2024
c6ad83e
added script to collect all quorum and non-quorum logs; added step in…
arnabghose997 May 15, 2024
54ae41e
reduced node liveness wait time from 60 seconds to 15 seconds
arnabghose997 May 15, 2024
15c4a5c
increased node liveness wait time to 40 seconds
arnabghose997 May 15, 2024
8e9174b
added OS alias in artifact name
arnabghose997 May 15, 2024
dcf3cd3
changed test swarm key
arnabghose997 May 15, 2024
a37bb4a
non quorums DIDs are now being registered for the RBT transfer transa…
arnabghose997 May 15, 2024
d96cdd6
added node_registry.json config to list all the node server indeces; …
arnabghose997 May 16, 2024
8eb6e5c
renamed test workflow artifiacts name
arnabghose997 May 16, 2024
c425be1
added test scenario for BIP39 and NLSS transfers
arnabghose997 May 17, 2024
70df360
added entry for .sh file extension
arnabghose997 May 17, 2024
460c0f6
created three swarm keys for each os environment
arnabghose997 May 20, 2024
9e9fce9
added timestamp for node log artifacts
arnabghose997 May 20, 2024
dc4e24e
removed unneeded print statement
arnabghose997 May 20, 2024
9de2633
Merge branch 'development' into maneesha/sender-signature-in-block-wi…
maneeSHA-256 May 22, 2024
b8e59a7
fix parse error in dump-token-chain
maneeSHA-256 May 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
TCSmartContractDataKey string = "9"
TCTokenValueKey string = "10"
TCChildTokensKey string = "11"
TCSenderSignatureKey string = "12"
)

const (
Expand All @@ -57,16 +58,17 @@ const (
)

type TokenChainBlock struct {
TransactionType string `json:"transactionType"`
TokenOwner string `json:"owner"`
GenesisBlock *GenesisBlock `json:"genesisBlock"`
TransInfo *TransInfo `json:"transInfo"`
PledgeDetails []PledgeDetail `json:"pledgeDetails"`
QuorumSignature []string `json:"quorumSignature"`
SmartContract []byte `json:"smartContract"`
SmartContractData string `json:"smartContractData"`
TokenValue float64 `json:"tokenValue"`
ChildTokens []string `json:"childTokens"`
TransactionType string `json:"transactionType"`
TokenOwner string `json:"owner"`
GenesisBlock *GenesisBlock `json:"genesisBlock"`
TransInfo *TransInfo `json:"transInfo"`
PledgeDetails []PledgeDetail `json:"pledgeDetails"`
QuorumSignature []CreditSignature `json:"quorumSignature"`
SmartContract []byte `json:"smartContract"`
SmartContractData string `json:"smartContractData"`
TokenValue float64 `json:"tokenValue"`
ChildTokens []string `json:"childTokens"`
SenderSignature *SenderSignature `json:"senderSignature"`
}

type PledgeDetail struct {
Expand All @@ -83,6 +85,22 @@ type Block struct {
log logger.Logger
}

type CreditSignature struct {
Signature string `json:"signature"`
PrivSignature string `json:"priv_signature"`
DID string `json:"did"`
Hash string `json:"hash"`
SignType string `json:"sign_type"` //represents sign type (PkiSign == 0 or NlssSign==1)
}

type SenderSignature struct {
NLSS_share string `json:"nlss_share_signature"`
Private_sign string `json:"priv_signature"`
DID string `json:"sender_did"`
Hash string `json:"hash"`
SignType int `json:"sign_type"` //represents sign type (PkiSign == 0 or NlssSign==1)
}

type BlockOption func(b *Block)

func NoSignature() BlockOption {
Expand Down Expand Up @@ -151,6 +169,9 @@ func CreateNewBlock(ctcb map[string]*Block, tcb *TokenChainBlock) *Block {
if tcb.SmartContractData != "" {
ntcb[TCSmartContractDataKey] = tcb.SmartContractData
}
if tcb.SenderSignature != nil {
ntcb[TCSenderSignatureKey] = tcb.SenderSignature
}

if floatPrecisionToMaxDecimalPlaces(tcb.TokenValue) > floatPrecisionToMaxDecimalPlaces(0) {
ntcb[TCTokenValueKey] = floatPrecisionToMaxDecimalPlaces(tcb.TokenValue)
Expand Down
52 changes: 35 additions & 17 deletions core/quorum_initiator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package core

import (
"encoding/json"
"errors"
"fmt"
"strconv"
Expand Down Expand Up @@ -129,7 +128,7 @@ type CreditSignature struct {
PrivSignature string `json:"priv_signature"`
DID string `json:"did"`
Hash string `json:"hash"`
SignVersion string `json:"sign_version"` //represents sign version (PkiSign == 0 or NlssSign==1)
SignType string `json:"sign_type"` //represents sign type (PkiSign == 0 or NlssSign==1)
}

type TokenArbitrationReq struct {
Expand Down Expand Up @@ -739,16 +738,16 @@ func (c *Core) finishConsensus(id string, qt int, p *ipfsport.Peer, status bool,
var pledgingDID string
if len(pledgingQuorumDID) > 0 {
pledgingDID = pledgingQuorumDID[0]
}
}

var signVersion string
var signType string

//signVersion = 0 => Pki based sign in lite mode
//signVersion = 1 => Nlss based sign in basic mode
//signType = 0 => Pki based sign in lite mode
//signType = 1 => Nlss based sign in basic mode
if util.HexToStr(ss) == "" {
signVersion = "0"
signType = "0"
} else {
signVersion = "1"
signType = "1"
}

switch qt {
Expand All @@ -761,15 +760,15 @@ func (c *Core) finishConsensus(id string, qt int, p *ipfsport.Peer, status bool,
PrivSignature: util.HexToStr(ps),
DID: did,
Hash: hash,
SignVersion: signVersion,
SignType: signType,
}
if cs.Result.SuccessCount < MinConsensusRequired-1 {
cs.P[did] = p
cs.Credit.Credit = append(cs.Credit.Credit, csig)
cs.Result.SuccessCount++
if did == pledgingDID {
cs.Result.PledgingDIDSignStatus = true
}
}
} else if (did == pledgingDID || cs.Result.PledgingDIDSignStatus) && cs.Result.SuccessCount == MinConsensusRequired-1 {
cs.P[did] = p
cs.Credit.Credit = append(cs.Credit.Credit, csig)
Expand Down Expand Up @@ -929,14 +928,16 @@ func (c *Core) pledgeQuorumToken(cr *ConensusRequest, sc *contract.Contract, tid
return nil, fmt.Errorf("invalid pledge request")
}
ti := sc.GetTransTokenInfo()
credit := make([]string, 0)
credit := make([]block.CreditSignature, 0)
for _, csig := range cs.Credit.Credit {
jb, err := json.Marshal(csig)
if err != nil {
c.log.Error("Failed to parse quorum credit", "err", err)
return nil, fmt.Errorf("failed to parse quorum credit")
}
credit = append(credit, string(jb))
credit_ := block.CreditSignature{
Signature: csig.Signature,
PrivSignature: csig.PrivSignature,
DID: csig.DID,
Hash: csig.Hash,
SignType: csig.SignType,
}
credit = append(credit, credit_)
}
ptds := make([]block.PledgeDetail, 0)
for k, v := range pd.PledgedTokens {
Expand Down Expand Up @@ -1004,6 +1005,22 @@ func (c *Core) pledgeQuorumToken(cr *ConensusRequest, sc *contract.Contract, tid
}
//tokenList = append(tokenList, cr.PartTokens...)

//Fetching sender signature to add it to transaction details
senderdid := sc.GetSenderDID()
sign_data, sender_share_sign, sender_priv_sign, err := sc.GetHashSig(senderdid)
if err != nil {
c.log.Error("failed to fetch sender sign", "err", err)
return nil, fmt.Errorf("failed to fetch sender sign")
}
sender_sign_type := dc.GetSignType()
sender_sign := &block.SenderSignature{
NLSS_share: sender_share_sign,
Private_sign: sender_priv_sign,
DID: senderdid,
Hash: sign_data,
SignType: sender_sign_type,
}

var tcb block.TokenChainBlock

if cr.Mode == SmartContractDeployMode {
Expand Down Expand Up @@ -1062,6 +1079,7 @@ func (c *Core) pledgeQuorumToken(cr *ConensusRequest, sc *contract.Contract, tid
QuorumSignature: credit,
SmartContract: sc.GetBlock(),
PledgeDetails: ptds,
SenderSignature: sender_sign,
}
}

Expand Down
2 changes: 2 additions & 0 deletions did/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func (d *DIDBasic) GetDID() string {
return d.did
}

// When the did creation and signing is done in Basic mode,
// this function returns the sign version as NLSSVersion = 1
func (d *DIDBasic) GetSignType() int {
return NlssVersion
}
Expand Down
2 changes: 2 additions & 0 deletions did/child.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func (d *DIDChild) GetDID() string {
return d.did
}

// When the did creation and signing is done in Child mode,
// this function returns the sign version as NLSSVersion = 1
func (d *DIDChild) GetSignType() int {
return NlssVersion
}
Expand Down
2 changes: 2 additions & 0 deletions did/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func (d *DIDStandard) GetDID() string {
return d.did
}

// When the did creation and signing is done in Standard mode,
// this function returns the sign version as NLSSVersion = 1
func (d *DIDStandard) GetSignType() int {
return NlssVersion
}
Expand Down
2 changes: 2 additions & 0 deletions did/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func (d *DIDWallet) GetDID() string {
return d.did
}

// When the did creation and signing is done in wallet mode,
// this function returns the sign version as NLSSVersion = 1
func (d *DIDWallet) GetSignType() int {
return NlssVersion
}
Expand Down