Ejemplo n.º 1
0
MasterCredential::MasterCredential(CredentialSet& theOwner, const NymParameters& nymParameters)
    : ot_super(theOwner, nymParameters, proto::CREDROLE_MASTERKEY)
{
    role_ = proto::CREDROLE_MASTERKEY;

    std::shared_ptr<NymIDSource> source;
    std::unique_ptr<proto::SourceProof> sourceProof;
    sourceProof.reset(new proto::SourceProof);

    proto::SourceProofType proofType = nymParameters.SourceProofType();

    if (proto::SOURCETYPE_PUBKEY == nymParameters.SourceType()) {
        OT_ASSERT_MSG(
            proto::SOURCEPROOFTYPE_SELF_SIGNATURE == proofType,
            "non self-signed credentials not yet implemented");

        source = std::make_shared<NymIDSource>(
            nymParameters,
            *(m_SigningKey->GetPublicKey().Serialize()));
        sourceProof->set_version(1);
        sourceProof->set_type(proto::SOURCEPROOFTYPE_SELF_SIGNATURE);

    } else if (proto::SOURCETYPE_BIP47 == nymParameters.SourceType()) {
        sourceProof->set_version(1);
        sourceProof->set_type(proto::SOURCEPROOFTYPE_SIGNATURE);

        std::unique_ptr<PaymentCode> bip47Source;
        bip47Source.reset(new PaymentCode(nymParameters.Nym()));

        source = std::make_shared<NymIDSource>(bip47Source);
    }

    source_proof_.reset(sourceProof.release());
    owner_backlink_->SetSource(source);
    String nymID = owner_backlink_->GetNymID();

    nym_id_ = nymID;
}