src/securityPolicy.c
security_policy_t policyForSignTxCertificateStaking(
        sign_tx_signingmode_t txSigningMode,
        const certificate_type_t certificateType,
        const stake_credential_t* stakeCredential
)
{
	switch (certificateType) {
	case CERTIFICATE_TYPE_STAKE_REGISTRATION:
	case CERTIFICATE_TYPE_STAKE_DEREGISTRATION:
	case CERTIFICATE_TYPE_STAKE_DELEGATION:
		break; // these are allowed

	default:
		ASSERT(false);
	}

	switch (stakeCredential->type) {
	case STAKE_CREDENTIAL_KEY_PATH:
		DENY_UNLESS(bip44_isOrdinaryStakingKeyPath(&stakeCredential->keyPath));
		DENY_IF(violatesSingleAccountOrStoreIt(&stakeCredential->keyPath));
		switch (txSigningMode) {
		case SIGN_TX_SIGNINGMODE_ORDINARY_TX:
		case SIGN_TX_SIGNINGMODE_PLUTUS_TX:
			PROMPT();
			break;

		case SIGN_TX_SIGNINGMODE_MULTISIG_TX:
			DENY();
			break;

		default:
			// in POOL_REGISTRATION signing modes, this certificate should have already been
			// reported as invalid (only pool registration certificate is allowed)
			ASSERT(false);
			break;
		}
		break;

	case STAKE_CREDENTIAL_KEY_HASH:
		switch (txSigningMode) {
		case SIGN_TX_SIGNINGMODE_PLUTUS_TX:
			PROMPT();
			break;

		case SIGN_TX_SIGNINGMODE_ORDINARY_TX:
		case SIGN_TX_SIGNINGMODE_MULTISIG_TX:
			DENY();
			break;

		default:
			// in POOL_REGISTRATION signing modes, this certificate should have already been
			// reported as invalid (only pool registration certificate is allowed)
			ASSERT(false);
			break;
		}
		break;

	case STAKE_CREDENTIAL_SCRIPT_HASH:
		switch (txSigningMode) {
		case SIGN_TX_SIGNINGMODE_MULTISIG_TX:
		case SIGN_TX_SIGNINGMODE_PLUTUS_TX:
			PROMPT();
			break;

		case SIGN_TX_SIGNINGMODE_ORDINARY_TX:
			DENY();
			break;

		default:
			// in POOL_REGISTRATION signing modes, this certificate should have already been
			// reported as invalid (only pool registration certificate is allowed)
			ASSERT(false);
			break;
		}
		break;

	default:
		ASSERT(false);
		break;
	}

	DENY(); // should not be reached
}
// for certificates concerning staking keys and stake delegation
for certificates concerning staking keys and stake delegation
for certificates concerning staking keys and stake delegation
security_policy_t policyForSignTxCertificateStaking(
        sign_tx_signingmode_t txSigningMode,
        const certificate_type_t certificateType,
        const stake_credential_t* stakeCredential
)
{
	switch (certificateType) {
	case CERTIFICATE_TYPE_STAKE_REGISTRATION:
	case CERTIFICATE_TYPE_STAKE_DEREGISTRATION:
	case CERTIFICATE_TYPE_STAKE_DELEGATION:
		break; 
	default:
		ASSERT(false);
	}
	switch (stakeCredential->type) {
	case STAKE_CREDENTIAL_KEY_PATH:
		DENY_UNLESS(bip44_isOrdinaryStakingKeyPath(&stakeCredential->keyPath));
		DENY_IF(violatesSingleAccountOrStoreIt(&stakeCredential->keyPath));
		switch (txSigningMode) {
		case SIGN_TX_SIGNINGMODE_ORDINARY_TX:
		case SIGN_TX_SIGNINGMODE_PLUTUS_TX:
			PROMPT();
			break;
		case SIGN_TX_SIGNINGMODE_MULTISIG_TX:
			DENY();
			break;
		default:
			ASSERT(false);
			break;
		}
		break;
	case STAKE_CREDENTIAL_KEY_HASH:
		switch (txSigningMode) {
		case SIGN_TX_SIGNINGMODE_PLUTUS_TX:
			PROMPT();
			break;
		case SIGN_TX_SIGNINGMODE_ORDINARY_TX:
		case SIGN_TX_SIGNINGMODE_MULTISIG_TX:
			DENY();
			break;
		default:
			ASSERT(false);
			break;
		}
		break;
	case STAKE_CREDENTIAL_SCRIPT_HASH:
		switch (txSigningMode) {
		case SIGN_TX_SIGNINGMODE_MULTISIG_TX:
		case SIGN_TX_SIGNINGMODE_PLUTUS_TX:
			PROMPT();
			break;
		case SIGN_TX_SIGNINGMODE_ORDINARY_TX:
			DENY();
			break;
		default:
			ASSERT(false);
			break;
		}
		break;
	default:
		ASSERT(false);
		break;
	}
	DENY(); 
}
security_policy_t policyForSignTxCertificateStaking ( sign_tx_signingmode_t txSigningMode , const certificate_type_t certificateType , const stake_credential_t * stakeCredential ) { switch ( certificateType ) { case CERTIFICATE_TYPE_STAKE_REGISTRATION : case CERTIFICATE_TYPE_STAKE_DEREGISTRATION : case CERTIFICATE_TYPE_STAKE_DELEGATION : break ; default : ASSERT ( false ) ; } switch ( stakeCredential -> type ) { case STAKE_CREDENTIAL_KEY_PATH : DENY_UNLESS ( bip44_isOrdinaryStakingKeyPath ( & stakeCredential -> keyPath ) ) ; DENY_IF ( violatesSingleAccountOrStoreIt ( & stakeCredential -> keyPath ) ) ; switch ( txSigningMode ) { case SIGN_TX_SIGNINGMODE_ORDINARY_TX : case SIGN_TX_SIGNINGMODE_PLUTUS_TX : PROMPT ( ) ; break ; case SIGN_TX_SIGNINGMODE_MULTISIG_TX : DENY ( ) ; break ; default : ASSERT ( false ) ; break ; } break ; case STAKE_CREDENTIAL_KEY_HASH : switch ( txSigningMode ) { case SIGN_TX_SIGNINGMODE_PLUTUS_TX : PROMPT ( ) ; break ; case SIGN_TX_SIGNINGMODE_ORDINARY_TX : case SIGN_TX_SIGNINGMODE_MULTISIG_TX : DENY ( ) ; break ; default : ASSERT ( false ) ; break ; } break ; case STAKE_CREDENTIAL_SCRIPT_HASH : switch ( txSigningMode ) { case SIGN_TX_SIGNINGMODE_MULTISIG_TX : case SIGN_TX_SIGNINGMODE_PLUTUS_TX : PROMPT ( ) ; break ; case SIGN_TX_SIGNINGMODE_ORDINARY_TX : DENY ( ) ; break ; default : ASSERT ( false ) ; break ; } break ; default : ASSERT ( false ) ; break ; } DENY ( ) ; }
for certificates concerning staking keys and stake delegation
for certificates concerning staking keys and stake delegation
// these are allowed // in POOL_REGISTRATION signing modes, this certificate should have already been // reported as invalid (only pool registration certificate is allowed) // in POOL_REGISTRATION signing modes, this certificate should have already been // reported as invalid (only pool registration certificate is allowed) // in POOL_REGISTRATION signing modes, this certificate should have already been // reported as invalid (only pool registration certificate is allowed) // should not be reached