Corda oracles verification












0














I'm trying to understand how corda oracles work from an example on github. It seems like in every example oracle verification function checks the data in command and data in output state. I don't understand why that should work because we (issuer node) manage that data and put it in command/output state.



// Our contract does not check that the Nth prime is correct. Instead, it checks that the
// information in the command and state match.
override fun verify(tx: LedgerTransaction) = requireThat {
"There are no inputs" using (tx.inputs.isEmpty())
val output = tx.outputsOfType<PrimeState>().single()
val command = tx.commands.requireSingleCommand<Create>().value
"The prime in the output does not match the prime in the command." using
(command.n == output.n && command.nthPrime == output.nthPrime)
}


In this example state gets Nth prime number from oracle but after it's issued the verification function doesn't rerun generateNth prime function to make sure that this number is really the one we needed. I understand that data in this example is deterministic since Nth prime cannot change but what about the case where we have dynamic data like stock values? Shouldn't oracle verification function also send another http request and get current values to check them?










share|improve this question


















  • 1




    The verify function you are looking at is that of the contract. The oracle only signs the Transaction if specified Nth Prime in the create Command is correct i.e. equal to the nth Prime obtained using the query method since it's deterministic, It'll be same each time. The Create command is created using the n and the nth prime received from Oracle.Oracle will not sign the Tx if doesn't get the same nth prime from query github.com/corda/oracle-example/blob/…
    – Kid101
    Nov 11 at 13:59








  • 1




    for your stock thing you will probably have to store it in Oracle's DB against which you'll validate before signing the tx that the stock price was actually something the oracle provided or make another http call to validate that the price at that point is same as in the command and only then sign the Tx.
    – Kid101
    Nov 11 at 14:02








  • 1




    you've to understand that something that is contractually valid doesn't mean that it's a valid transaction. The other party i.e. the oracle also has to agree to it. if the Tx is not as what Oracle sees it. It's an invalid Tx and will not sign the Tx. as you'd see Signatures of Oracle is mandatory and the tx would fail if he doesn't provide his signature.
    – Kid101
    Nov 11 at 14:13
















0














I'm trying to understand how corda oracles work from an example on github. It seems like in every example oracle verification function checks the data in command and data in output state. I don't understand why that should work because we (issuer node) manage that data and put it in command/output state.



// Our contract does not check that the Nth prime is correct. Instead, it checks that the
// information in the command and state match.
override fun verify(tx: LedgerTransaction) = requireThat {
"There are no inputs" using (tx.inputs.isEmpty())
val output = tx.outputsOfType<PrimeState>().single()
val command = tx.commands.requireSingleCommand<Create>().value
"The prime in the output does not match the prime in the command." using
(command.n == output.n && command.nthPrime == output.nthPrime)
}


In this example state gets Nth prime number from oracle but after it's issued the verification function doesn't rerun generateNth prime function to make sure that this number is really the one we needed. I understand that data in this example is deterministic since Nth prime cannot change but what about the case where we have dynamic data like stock values? Shouldn't oracle verification function also send another http request and get current values to check them?










share|improve this question


















  • 1




    The verify function you are looking at is that of the contract. The oracle only signs the Transaction if specified Nth Prime in the create Command is correct i.e. equal to the nth Prime obtained using the query method since it's deterministic, It'll be same each time. The Create command is created using the n and the nth prime received from Oracle.Oracle will not sign the Tx if doesn't get the same nth prime from query github.com/corda/oracle-example/blob/…
    – Kid101
    Nov 11 at 13:59








  • 1




    for your stock thing you will probably have to store it in Oracle's DB against which you'll validate before signing the tx that the stock price was actually something the oracle provided or make another http call to validate that the price at that point is same as in the command and only then sign the Tx.
    – Kid101
    Nov 11 at 14:02








  • 1




    you've to understand that something that is contractually valid doesn't mean that it's a valid transaction. The other party i.e. the oracle also has to agree to it. if the Tx is not as what Oracle sees it. It's an invalid Tx and will not sign the Tx. as you'd see Signatures of Oracle is mandatory and the tx would fail if he doesn't provide his signature.
    – Kid101
    Nov 11 at 14:13














0












0








0







I'm trying to understand how corda oracles work from an example on github. It seems like in every example oracle verification function checks the data in command and data in output state. I don't understand why that should work because we (issuer node) manage that data and put it in command/output state.



// Our contract does not check that the Nth prime is correct. Instead, it checks that the
// information in the command and state match.
override fun verify(tx: LedgerTransaction) = requireThat {
"There are no inputs" using (tx.inputs.isEmpty())
val output = tx.outputsOfType<PrimeState>().single()
val command = tx.commands.requireSingleCommand<Create>().value
"The prime in the output does not match the prime in the command." using
(command.n == output.n && command.nthPrime == output.nthPrime)
}


In this example state gets Nth prime number from oracle but after it's issued the verification function doesn't rerun generateNth prime function to make sure that this number is really the one we needed. I understand that data in this example is deterministic since Nth prime cannot change but what about the case where we have dynamic data like stock values? Shouldn't oracle verification function also send another http request and get current values to check them?










share|improve this question













I'm trying to understand how corda oracles work from an example on github. It seems like in every example oracle verification function checks the data in command and data in output state. I don't understand why that should work because we (issuer node) manage that data and put it in command/output state.



// Our contract does not check that the Nth prime is correct. Instead, it checks that the
// information in the command and state match.
override fun verify(tx: LedgerTransaction) = requireThat {
"There are no inputs" using (tx.inputs.isEmpty())
val output = tx.outputsOfType<PrimeState>().single()
val command = tx.commands.requireSingleCommand<Create>().value
"The prime in the output does not match the prime in the command." using
(command.n == output.n && command.nthPrime == output.nthPrime)
}


In this example state gets Nth prime number from oracle but after it's issued the verification function doesn't rerun generateNth prime function to make sure that this number is really the one we needed. I understand that data in this example is deterministic since Nth prime cannot change but what about the case where we have dynamic data like stock values? Shouldn't oracle verification function also send another http request and get current values to check them?







corda






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 13:22









Michael Metreveli

617




617








  • 1




    The verify function you are looking at is that of the contract. The oracle only signs the Transaction if specified Nth Prime in the create Command is correct i.e. equal to the nth Prime obtained using the query method since it's deterministic, It'll be same each time. The Create command is created using the n and the nth prime received from Oracle.Oracle will not sign the Tx if doesn't get the same nth prime from query github.com/corda/oracle-example/blob/…
    – Kid101
    Nov 11 at 13:59








  • 1




    for your stock thing you will probably have to store it in Oracle's DB against which you'll validate before signing the tx that the stock price was actually something the oracle provided or make another http call to validate that the price at that point is same as in the command and only then sign the Tx.
    – Kid101
    Nov 11 at 14:02








  • 1




    you've to understand that something that is contractually valid doesn't mean that it's a valid transaction. The other party i.e. the oracle also has to agree to it. if the Tx is not as what Oracle sees it. It's an invalid Tx and will not sign the Tx. as you'd see Signatures of Oracle is mandatory and the tx would fail if he doesn't provide his signature.
    – Kid101
    Nov 11 at 14:13














  • 1




    The verify function you are looking at is that of the contract. The oracle only signs the Transaction if specified Nth Prime in the create Command is correct i.e. equal to the nth Prime obtained using the query method since it's deterministic, It'll be same each time. The Create command is created using the n and the nth prime received from Oracle.Oracle will not sign the Tx if doesn't get the same nth prime from query github.com/corda/oracle-example/blob/…
    – Kid101
    Nov 11 at 13:59








  • 1




    for your stock thing you will probably have to store it in Oracle's DB against which you'll validate before signing the tx that the stock price was actually something the oracle provided or make another http call to validate that the price at that point is same as in the command and only then sign the Tx.
    – Kid101
    Nov 11 at 14:02








  • 1




    you've to understand that something that is contractually valid doesn't mean that it's a valid transaction. The other party i.e. the oracle also has to agree to it. if the Tx is not as what Oracle sees it. It's an invalid Tx and will not sign the Tx. as you'd see Signatures of Oracle is mandatory and the tx would fail if he doesn't provide his signature.
    – Kid101
    Nov 11 at 14:13








1




1




The verify function you are looking at is that of the contract. The oracle only signs the Transaction if specified Nth Prime in the create Command is correct i.e. equal to the nth Prime obtained using the query method since it's deterministic, It'll be same each time. The Create command is created using the n and the nth prime received from Oracle.Oracle will not sign the Tx if doesn't get the same nth prime from query github.com/corda/oracle-example/blob/…
– Kid101
Nov 11 at 13:59






The verify function you are looking at is that of the contract. The oracle only signs the Transaction if specified Nth Prime in the create Command is correct i.e. equal to the nth Prime obtained using the query method since it's deterministic, It'll be same each time. The Create command is created using the n and the nth prime received from Oracle.Oracle will not sign the Tx if doesn't get the same nth prime from query github.com/corda/oracle-example/blob/…
– Kid101
Nov 11 at 13:59






1




1




for your stock thing you will probably have to store it in Oracle's DB against which you'll validate before signing the tx that the stock price was actually something the oracle provided or make another http call to validate that the price at that point is same as in the command and only then sign the Tx.
– Kid101
Nov 11 at 14:02






for your stock thing you will probably have to store it in Oracle's DB against which you'll validate before signing the tx that the stock price was actually something the oracle provided or make another http call to validate that the price at that point is same as in the command and only then sign the Tx.
– Kid101
Nov 11 at 14:02






1




1




you've to understand that something that is contractually valid doesn't mean that it's a valid transaction. The other party i.e. the oracle also has to agree to it. if the Tx is not as what Oracle sees it. It's an invalid Tx and will not sign the Tx. as you'd see Signatures of Oracle is mandatory and the tx would fail if he doesn't provide his signature.
– Kid101
Nov 11 at 14:13




you've to understand that something that is contractually valid doesn't mean that it's a valid transaction. The other party i.e. the oracle also has to agree to it. if the Tx is not as what Oracle sees it. It's an invalid Tx and will not sign the Tx. as you'd see Signatures of Oracle is mandatory and the tx would fail if he doesn't provide his signature.
– Kid101
Nov 11 at 14:13












1 Answer
1






active

oldest

votes


















0














Firstly, note that contracts in Corda are not able to access the outside world in any way (DB reads, HTTP requests, etc.). If they could, transaction validity would be non-deterministic. A transaction that is found to be valid on day n may become invalid on day n+1 (because a database row changed, or a website went down, etc.). This would cause disagreements about whether a given transaction was a valid ledger update.



However, we sometimes need a transaction to include external data for verification (whether a company is bankrupt, whether a natural catastrophe happened, etc.). To do this, we use a trusted oracle that only signs the transaction if a given piece of data is valid.



We could embed the information in the input or output states. However, this would require us to reveal the entire input or output state to the oracle for signing. For privacy reasons, it is therefore preferable to embed the data in a command that only contains the data of interest to the oracle, so that we can filter out all the other parts of the transaction and only present this command to the oracle for signing.



The oracle will usually perform a DB read or make an HTTP request to check the validity of the data before signing.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249156%2fcorda-oracles-verification%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Firstly, note that contracts in Corda are not able to access the outside world in any way (DB reads, HTTP requests, etc.). If they could, transaction validity would be non-deterministic. A transaction that is found to be valid on day n may become invalid on day n+1 (because a database row changed, or a website went down, etc.). This would cause disagreements about whether a given transaction was a valid ledger update.



    However, we sometimes need a transaction to include external data for verification (whether a company is bankrupt, whether a natural catastrophe happened, etc.). To do this, we use a trusted oracle that only signs the transaction if a given piece of data is valid.



    We could embed the information in the input or output states. However, this would require us to reveal the entire input or output state to the oracle for signing. For privacy reasons, it is therefore preferable to embed the data in a command that only contains the data of interest to the oracle, so that we can filter out all the other parts of the transaction and only present this command to the oracle for signing.



    The oracle will usually perform a DB read or make an HTTP request to check the validity of the data before signing.






    share|improve this answer


























      0














      Firstly, note that contracts in Corda are not able to access the outside world in any way (DB reads, HTTP requests, etc.). If they could, transaction validity would be non-deterministic. A transaction that is found to be valid on day n may become invalid on day n+1 (because a database row changed, or a website went down, etc.). This would cause disagreements about whether a given transaction was a valid ledger update.



      However, we sometimes need a transaction to include external data for verification (whether a company is bankrupt, whether a natural catastrophe happened, etc.). To do this, we use a trusted oracle that only signs the transaction if a given piece of data is valid.



      We could embed the information in the input or output states. However, this would require us to reveal the entire input or output state to the oracle for signing. For privacy reasons, it is therefore preferable to embed the data in a command that only contains the data of interest to the oracle, so that we can filter out all the other parts of the transaction and only present this command to the oracle for signing.



      The oracle will usually perform a DB read or make an HTTP request to check the validity of the data before signing.






      share|improve this answer
























        0












        0








        0






        Firstly, note that contracts in Corda are not able to access the outside world in any way (DB reads, HTTP requests, etc.). If they could, transaction validity would be non-deterministic. A transaction that is found to be valid on day n may become invalid on day n+1 (because a database row changed, or a website went down, etc.). This would cause disagreements about whether a given transaction was a valid ledger update.



        However, we sometimes need a transaction to include external data for verification (whether a company is bankrupt, whether a natural catastrophe happened, etc.). To do this, we use a trusted oracle that only signs the transaction if a given piece of data is valid.



        We could embed the information in the input or output states. However, this would require us to reveal the entire input or output state to the oracle for signing. For privacy reasons, it is therefore preferable to embed the data in a command that only contains the data of interest to the oracle, so that we can filter out all the other parts of the transaction and only present this command to the oracle for signing.



        The oracle will usually perform a DB read or make an HTTP request to check the validity of the data before signing.






        share|improve this answer












        Firstly, note that contracts in Corda are not able to access the outside world in any way (DB reads, HTTP requests, etc.). If they could, transaction validity would be non-deterministic. A transaction that is found to be valid on day n may become invalid on day n+1 (because a database row changed, or a website went down, etc.). This would cause disagreements about whether a given transaction was a valid ledger update.



        However, we sometimes need a transaction to include external data for verification (whether a company is bankrupt, whether a natural catastrophe happened, etc.). To do this, we use a trusted oracle that only signs the transaction if a given piece of data is valid.



        We could embed the information in the input or output states. However, this would require us to reveal the entire input or output state to the oracle for signing. For privacy reasons, it is therefore preferable to embed the data in a command that only contains the data of interest to the oracle, so that we can filter out all the other parts of the transaction and only present this command to the oracle for signing.



        The oracle will usually perform a DB read or make an HTTP request to check the validity of the data before signing.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 16:43









        Joel

        10k11227




        10k11227






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249156%2fcorda-oracles-verification%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini