diff --git a/app/specs/cite/spec.json b/app/specs/cite/spec.json new file mode 100644 index 00000000..237ca002 --- /dev/null +++ b/app/specs/cite/spec.json @@ -0,0 +1,334 @@ +{ + "name": "cite", + "comment": "The cite operation of the annotation facet (app/src/PrismCite.lex.tex): from a reply's address and, for each of its placeholders, where it starts and ends in the reply's text, the address of the item it was filled from and the exact text taken, the citations of that reply as W3C Web Annotations. A request is the reply's address and a line end, then per citation ' ', a line end, the n bytes of the exact text and a line end; the reply's address is 'sha256:' and 64 lower-case hex digits, and an item's address is the one the page holds it at: letters, digits and : # - _ . only, at most 100 bytes. The answer is a JSON array in RFC 8785 form, one annotation per citation: its motivation is linking, its target a Specific Resource on the reply selected by a TextPositionSelector (Recommendation 4.2.5), its body a Specific Resource on the item selected by a TextQuoteSelector (4.2.4), its id 'sha256:' and the SHA-256 of the annotation without an id. An annotation is answered only when the annotation judge (PrismAnnotation, held to the web-platform-tests annotation-model suite) finds every annotationMusts assertion as the suite expects; otherwise, and for a request not of this form, the answer is invalid. 'examples' are the acceptance vectors. No expected answer is the model's own output: each is built outside LexLean as an object of that shape, written by the RFC 8785 author's canonicalizer ('canonicalizer'), addressed by SHA-256 and accepted by the suite's own validator ('suite' in app/specs/annotation/spec.json). The exact texts and positions are the TextQuoteSelector and TextPositionSelector values of the W3C documents pinned there and the strings of the RFC 8785 author's test data (app/specs/oracle/json-canonicalization); the addresses are digests of NIST's SHA-256 short messages (app/specs/oracle/nist-cavp-sha256), an item's written in the page's forms ('k1:' and the hex, that with '#event', or 'sha256:' and the hex). The fifth example from the end is an item address the suite's validator does not take as an IRI. The last four are refusals the request form itself defines: an end before its start, a reply address that is not sha256, a text shorter than its stated length, an item address over 100 bytes.", + "canonicalizer": { + "url": "https://raw.githubusercontent.com/cyberphone/json-canonicalization/32a48195b9b20fe67b1795e39e4509f14d860b45/node-es6/canonicalize.js", + "sha256": "f9f498b55c99eefe348c99018ddcfe08efa6f7ff96b9ba9dce4b7090b33c4438" + }, + "suite": { + "revision": "81999813d59bc596c8029aba931bb550ab9f5a28", + "test": "annotations/annotationMusts.test" + }, + "vectors": [ + { + "why": "a reply that cites nothing", + "content": [] + }, + { + "why": "one citation", + "content": [ + [ + "w3c/web-annotation model/wd2/examples/correct/anno23.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "one citation", + "content": [ + [ + "w3c/web-annotation model/wd2/examples/correct/anno29.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "several citations of one reply", + "content": [ + [ + "w3c/web-annotation model/wd2/examples/correct/anno23.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ], + [ + "w3c/web-annotation model/wd2/examples/correct/anno29.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/unicode.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/values.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/weird.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/french.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/french.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/french.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/french.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/structures.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/structures.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/structures.json", + "w3c/web-annotation model/wd2/examples/correct/anno38.json" + ] + ] + }, + { + "why": "text RFC 8785 writes with escapes or as it is", + "content": [ + [ + "json-canonicalization testdata/input/structures.json", + "w3c/web-annotation model/wd2/examples/correct/anno24.json" + ] + ] + } + ], + "examples": [ + [ + "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n", + "[]" + ], + [ + "sha256:28969cdfa74a12c82f3bad960b0b000aca2ac329deea5c2328ebc6f2ba9802c1\n412 795 k1:5ca7133fa735326081558ac312c620eeca9970d1e70a4b95533d956f072d1f98 9\nanotation\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"anotation\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:5ca7133fa735326081558ac312c620eeca9970d1e70a4b95533d956f072d1f98\",\"type\":\"SpecificResource\"},\"id\":\"sha256:7cb16ea868bc8833439e9307af8b782ff4831625e511f3cc32219c21c0858148\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:28969cdfa74a12c82f3bad960b0b000aca2ac329deea5c2328ebc6f2ba9802c1\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:dff2e73091f6c05e528896c4c831b9448653dc2ff043528f6769437bc7b975c2\n6 27 k1:b16aa56be3880d18cd41e68384cf1ec8c17680c45a02b1575dc1518923ae8b0e#event 13\nSelected Text\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Selected Text\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:b16aa56be3880d18cd41e68384cf1ec8c17680c45a02b1575dc1518923ae8b0e#event\",\"type\":\"SpecificResource\"},\"id\":\"sha256:4eea779e95cb9f6ceda73dde3238423c2a538c93f8b55da8f22dec3626d09053\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:dff2e73091f6c05e528896c4c831b9448653dc2ff043528f6769437bc7b975c2\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:f0887fe961c9cd3beab957e8222494abb969b1ce4c6557976df8b0f6d20e9166\n412 795 sha256:eca0a060b489636225b4fa64d267dabbe44273067ac679f20820bddc6b6a90ac 9\nanotation\n6 27 k1:3fd877e27450e6bbd5d74bb82f9870c64c66e109418baa8e6bbcff355e287926 13\nSelected Text\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"anotation\",\"type\":\"TextQuoteSelector\"},\"source\":\"sha256:eca0a060b489636225b4fa64d267dabbe44273067ac679f20820bddc6b6a90ac\",\"type\":\"SpecificResource\"},\"id\":\"sha256:ae1d2685b9753c4dd97f163c544c5ebd621dce6e40d730a2b85f0bbf34dd5c76\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:f0887fe961c9cd3beab957e8222494abb969b1ce4c6557976df8b0f6d20e9166\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"},{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Selected Text\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:3fd877e27450e6bbd5d74bb82f9870c64c66e109418baa8e6bbcff355e287926\",\"type\":\"SpecificResource\"},\"id\":\"sha256:9f08ca85e718e4adbef4095d4668700a83db18d8ffa4ff076f9f9c80109bf004\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:f0887fe961c9cd3beab957e8222494abb969b1ce4c6557976df8b0f6d20e9166\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:963bb88f27f512777aab6c8b1a02c70ec0ad651d428f870036e1917120fb48bf\n412 795 k1:078da3d77ed43bd3037a433fd0341855023793f9afd08b4b08ea1e5597ceef20#event 3\nÅ\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Å\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:078da3d77ed43bd3037a433fd0341855023793f9afd08b4b08ea1e5597ceef20#event\",\"type\":\"SpecificResource\"},\"id\":\"sha256:f8d285c893c371825d1a036b5d8295d49789c5f5b015629651045014670f5973\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:963bb88f27f512777aab6c8b1a02c70ec0ad651d428f870036e1917120fb48bf\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:73d6fad1caaa75b43b21733561fd3958bdc555194a037c2addec19dc2d7a52bd\n6 27 sha256:044cef802901932e46dc46b2545e6c99c0fc323a0ed99b081bda4216857f38ac 14\n€$\u000f\nA'B\"\\\\\"/\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"€$\\u000f\\nA'B\\\"\\\\\\\\\\\"/\",\"type\":\"TextQuoteSelector\"},\"source\":\"sha256:044cef802901932e46dc46b2545e6c99c0fc323a0ed99b081bda4216857f38ac\",\"type\":\"SpecificResource\"},\"id\":\"sha256:0acf622d8da4fdf8f289c0530429ca920777df5612085511f8c62ec804814d6d\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:73d6fad1caaa75b43b21733561fd3958bdc555194a037c2addec19dc2d7a52bd\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:fe56287cd657e4afc50dba7a3a54c2a6324b886becdcd1fae473b769e551a09b\n412 795 k1:af53430466715e99a602fc9f5945719b04dd24267e6a98471f7a7869bd3b4313 3\nOne\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"One\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:af53430466715e99a602fc9f5945719b04dd24267e6a98471f7a7869bd3b4313\",\"type\":\"SpecificResource\"},\"id\":\"sha256:6af0bf5fab538a52bb4628c9cc59687b09138660726ae991bc9d3fb1e3f45c34\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:fe56287cd657e4afc50dba7a3a54c2a6324b886becdcd1fae473b769e551a09b\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:d189498a3463b18e846b8ab1b41583b0b7efc789dad8a7fb885bbf8fb5b45c5c\n6 27 k1:dcbaf335360de853b9cddfdafb90fa75567d0d3d58af8db9d764113aef570125#event 9\nEuro Sign\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Euro Sign\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:dcbaf335360de853b9cddfdafb90fa75567d0d3d58af8db9d764113aef570125#event\",\"type\":\"SpecificResource\"},\"id\":\"sha256:903c127f95d305d3532087521c918d1f694cc79e4201c232b7755ece0aca51f0\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:d189498a3463b18e846b8ab1b41583b0b7efc789dad8a7fb885bbf8fb5b45c5c\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:80c25ec1600587e7f28b18b1b18e3cdc89928e39cab3bc25e4d4a4c139bcedc4\n412 795 sha256:d5c30315f72ed05fe519a1bf75ab5fd0ffec5ac1acb0daf66b6b769598594509 15\nCarriage Return\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Carriage Return\",\"type\":\"TextQuoteSelector\"},\"source\":\"sha256:d5c30315f72ed05fe519a1bf75ab5fd0ffec5ac1acb0daf66b6b769598594509\",\"type\":\"SpecificResource\"},\"id\":\"sha256:5f24fd316fc55754a4614a23c88ab3b9b9c2fefaf6894d73922d26a258c335bb\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:80c25ec1600587e7f28b18b1b18e3cdc89928e39cab3bc25e4d4a4c139bcedc4\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:32c38c54189f2357e96bd77eb00c2b9c341ebebacc2945f97804f59a93238288\n6 27 k1:9b5b37816de8fcdf3ec10b745428708df8f391c550ea6746b2cafe019c2b6ace 7\nNewline\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Newline\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:9b5b37816de8fcdf3ec10b745428708df8f391c550ea6746b2cafe019c2b6ace\",\"type\":\"SpecificResource\"},\"id\":\"sha256:efd41181a178483fd3e0e112985c8e4b5f749fc91ac661262228fbb0ec319023\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:32c38c54189f2357e96bd77eb00c2b9c341ebebacc2945f97804f59a93238288\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:6dd52b0d8b48cc8146cebd0216fbf5f6ef7eeafc0ff2ff9d1422d6345555a142\n412 795 k1:44d34809fc60d1fcafa7f37b794d1d3a765dd0d23194ebbe340f013f0c39b613#event 8\nControl\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Control\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:44d34809fc60d1fcafa7f37b794d1d3a765dd0d23194ebbe340f013f0c39b613#event\",\"type\":\"SpecificResource\"},\"id\":\"sha256:00196b4a938e57c2486e4822691847d484d775012803f74ab669a1b5f115dccc\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:6dd52b0d8b48cc8146cebd0216fbf5f6ef7eeafc0ff2ff9d1422d6345555a142\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:9df5c16a3f580406f07d96149303d8c408869b32053b726cf3defd241e484957\n6 27 sha256:672b54e43f41ee77584bdf8bf854d97b6252c918f7ea2d26bc4097ea53a88f10 6\nSmiley\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Smiley\",\"type\":\"TextQuoteSelector\"},\"source\":\"sha256:672b54e43f41ee77584bdf8bf854d97b6252c918f7ea2d26bc4097ea53a88f10\",\"type\":\"SpecificResource\"},\"id\":\"sha256:241ea8a6a5ae260c30c349ee5f85f237d2330aa5eb4f2cdb56504c54defb8158\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:9df5c16a3f580406f07d96149303d8c408869b32053b726cf3defd241e484957\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:feeb4b2b59fec8fdb1e55194a493d8c871757b5723675e93d3ac034b380b7fc9\n412 795 k1:76e3acbc718836f2df8ad2d0d2d76f0cfa5fea0986be918f10bcee730df441b9 35\nLatin Small Letter O With Diaeresis\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Latin Small Letter O With Diaeresis\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:76e3acbc718836f2df8ad2d0d2d76f0cfa5fea0986be918f10bcee730df441b9\",\"type\":\"SpecificResource\"},\"id\":\"sha256:dd98a121f5e5f09d08738ffe88f1e5540944431ef2a923b2fa044103204113af\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:feeb4b2b59fec8fdb1e55194a493d8c871757b5723675e93d3ac034b380b7fc9\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:6733809c73e53666c735b3bd3daf87ebc77c72756150a616a194108d71231272\n6 27 k1:0e6e3c143c3a5f7f38505ed6adc9b48c18edf6dedf11635f6e8f9ac73c39fe9e#event 31\nHebrew Letter Dalet With Dagesh\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Hebrew Letter Dalet With Dagesh\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:0e6e3c143c3a5f7f38505ed6adc9b48c18edf6dedf11635f6e8f9ac73c39fe9e#event\",\"type\":\"SpecificResource\"},\"id\":\"sha256:e191f5bcf51ed9f6bd4e224416ac80bd5d8a1dd1f37a79ca534409373d883c69\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:6733809c73e53666c735b3bd3daf87ebc77c72756150a616a194108d71231272\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:ffb4fc03e054f8ecbc31470fc023bedcd4a406b9dd56c71da1b660dcc4842c65\n412 795 sha256:c644612cd326b38b1c6813b1daded34448805aef317c35f548dfb4a0d74b8106 17\nBrowser Challenge\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"Browser Challenge\",\"type\":\"TextQuoteSelector\"},\"source\":\"sha256:c644612cd326b38b1c6813b1daded34448805aef317c35f548dfb4a0d74b8106\",\"type\":\"SpecificResource\"},\"id\":\"sha256:0a95481e3e3e08617a403bfa94ca2356798f217e923999a295f38efe0c1c51bf\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:ffb4fc03e054f8ecbc31470fc023bedcd4a406b9dd56c71da1b660dcc4842c65\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:c0e29eeeb0d3a7707947e623cdc7d1899adc70dd7861205ea5e5813954fb7957\n6 27 k1:a4139b74b102cf1e2fce229a6cd84c87501f50afa4c80feacf7d8cf5ed94f042 18\nThis sorting order\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"This sorting order\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:a4139b74b102cf1e2fce229a6cd84c87501f50afa4c80feacf7d8cf5ed94f042\",\"type\":\"SpecificResource\"},\"id\":\"sha256:09b19cc71a0d2342c44179c17e145295e6bcbf1c6baf77f16dc221c76ca43a69\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:c0e29eeeb0d3a7707947e623cdc7d1899adc70dd7861205ea5e5813954fb7957\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:4f44c1c7fbebb6f9601829f3897bfd650c56fa07844be76489076356ac1886a4\n412 795 k1:b31ad3cd02b10db282b3576c059b746fb24ca6f09fef69402dc90ece7421cbb7#event 28\nis wrong according to French\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"is wrong according to French\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:b31ad3cd02b10db282b3576c059b746fb24ca6f09fef69402dc90ece7421cbb7#event\",\"type\":\"SpecificResource\"},\"id\":\"sha256:e277a7a6c4183bd4ec4c87f766b2e3203d80655ad6d4a0a30d70457ba77093ad\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:4f44c1c7fbebb6f9601829f3897bfd650c56fa07844be76489076356ac1886a4\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:1c38bf6bbfd32292d67d1d651fd9d5b623b6ec1e854406223f51d0df46968712\n6 27 sha256:c2684c0dbb85c232b6da4fb5147dd0624429ec7e657991edd95eda37a587269e 25\nbut canonicalization MUST\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"but canonicalization MUST\",\"type\":\"TextQuoteSelector\"},\"source\":\"sha256:c2684c0dbb85c232b6da4fb5147dd0624429ec7e657991edd95eda37a587269e\",\"type\":\"SpecificResource\"},\"id\":\"sha256:a212c3cd4de98b283f08599eb6e4e6a29b5b9472eddb94216f7e2daef2a93523\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:1c38bf6bbfd32292d67d1d651fd9d5b623b6ec1e854406223f51d0df46968712\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:bf9d5e5b5393053f055b380baed7e792ae85ad37c0ada5fd4519542ccc461cf3\n412 795 k1:d1f8bd684001ac5a4b67bbf79f87de524d2da99ac014dec3e4187728f4557471 13\nignore locale\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"ignore locale\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:d1f8bd684001ac5a4b67bbf79f87de524d2da99ac014dec3e4187728f4557471\",\"type\":\"SpecificResource\"},\"id\":\"sha256:d9c9d0d2a009958ae69f91fc79fce7465244d9be78c8049d30b239cb71aad357\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:bf9d5e5b5393053f055b380baed7e792ae85ad37c0ada5fd4519542ccc461cf3\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:49ba38db85c2796f85ffd57dd5ec337007414528ae33935b102d16a6b91ba6c1\n6 27 k1:725e6f8d888ebaf908b7692259ab8839c3248edd22ca115bb13e025808654700#event 2\nhi\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"hi\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:725e6f8d888ebaf908b7692259ab8839c3248edd22ca115bb13e025808654700#event\",\"type\":\"SpecificResource\"},\"id\":\"sha256:6eab68cd0315afbcddb4b3ec3dca7ea368034e6234e207fd70d876e5731f65c8\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:49ba38db85c2796f85ffd57dd5ec337007414528ae33935b102d16a6b91ba6c1\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:32caef024f84e97c30b4a7b9d04b678b3d8a6eb2259dff5b7f7c011f090845f8\n412 795 sha256:4bb33e7c6916e08a9b3ed6bcef790aaaee0dcf2e7a01afb056182dea2dad7d63 3\nyes\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"yes\",\"type\":\"TextQuoteSelector\"},\"source\":\"sha256:4bb33e7c6916e08a9b3ed6bcef790aaaee0dcf2e7a01afb056182dea2dad7d63\",\"type\":\"SpecificResource\"},\"id\":\"sha256:f9f982840151fc193e3df24ba19de8cbd11f5a8b3af6360b8326df10cb764925\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:32caef024f84e97c30b4a7b9d04b678b3d8a6eb2259dff5b7f7c011f090845f8\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:3ac7ac6bed82fdc8cd15b746f0ee7489158192c238f371c1883c9fe90b3e2831\n6 27 k1:bfce809534eefe871273964d32f091fe756c71a7f512ef5f2300bcd57f699e74 2\nno\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"no\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:bfce809534eefe871273964d32f091fe756c71a7f512ef5f2300bcd57f699e74\",\"type\":\"SpecificResource\"},\"id\":\"sha256:eef6bb8df260bca527d7d0f5ac46343e7e75e94780efdef9fd25b93926784acd\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":27,\"start\":6,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:3ac7ac6bed82fdc8cd15b746f0ee7489158192c238f371c1883c9fe90b3e2831\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:1d26f3e04f89b4eaa9dbed9231bb051eef2e8311ad26fe53d0bf0b821eaf7567\n412 795 k1:0ffeb644a49e787ccc6970fe29705a4f4c2bfcfe7d19741c158333ff6982cc9c#event 5\nempty\n", + "[{\"@context\":\"http://www.w3.org/ns/anno.jsonld\",\"body\":{\"selector\":{\"exact\":\"empty\",\"type\":\"TextQuoteSelector\"},\"source\":\"k1:0ffeb644a49e787ccc6970fe29705a4f4c2bfcfe7d19741c158333ff6982cc9c#event\",\"type\":\"SpecificResource\"},\"id\":\"sha256:94b0a07bd9d385a1917100590dba4ed110e0ac90d7db9d7d1cd081bc5e8acc9a\",\"motivation\":\"linking\",\"target\":{\"selector\":{\"end\":795,\"start\":412,\"type\":\"TextPositionSelector\"},\"source\":\"sha256:1d26f3e04f89b4eaa9dbed9231bb051eef2e8311ad26fe53d0bf0b821eaf7567\",\"type\":\"SpecificResource\"},\"type\":\"Annotation\"}]" + ], + [ + "sha256:d048ee1524014adf9a56e60a388277de194c694cc787fc5a1b554ea9f07abfdf\n412 795 abc 9\nanotation\n", + "invalid" + ], + [ + "sha256:28969cdfa74a12c82f3bad960b0b000aca2ac329deea5c2328ebc6f2ba9802c1\n795 412 k1:5ca7133fa735326081558ac312c620eeca9970d1e70a4b95533d956f072d1f98 1\nx\n", + "invalid" + ], + [ + "sha512:28969cdfa74a12c82f3bad960b0b000aca2ac329deea5c2328ebc6f2ba9802c1\n", + "invalid" + ], + [ + "sha256:28969cdfa74a12c82f3bad960b0b000aca2ac329deea5c2328ebc6f2ba9802c1\n0 1 k1:5ca7133fa735326081558ac312c620eeca9970d1e70a4b95533d956f072d1f98 2\nx\n", + "invalid" + ], + [ + "sha256:28969cdfa74a12c82f3bad960b0b000aca2ac329deea5c2328ebc6f2ba9802c1\n0 1 k1:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1\nx\n", + "invalid" + ] + ] +} diff --git a/app/specs/guests/annotation/annotation.json b/app/specs/guests/annotation/annotation.json index 03ee0985..3e876bd9 100644 --- a/app/specs/guests/annotation/annotation.json +++ b/app/specs/guests/annotation/annotation.json @@ -2,6 +2,7 @@ "id": "annotation", "wasm": "site/annotation/guest/annotation.wasm", "pin": "site/annotation/guest.mjs", + "as": "judge", "modules": [ "PrismAnnotationTable", "PrismAnnotation" diff --git a/app/specs/guests/annotation/cite.json b/app/specs/guests/annotation/cite.json new file mode 100644 index 00000000..497a4e7b --- /dev/null +++ b/app/specs/guests/annotation/cite.json @@ -0,0 +1,23 @@ +{ + "id": "cite", + "wasm": "site/annotation/guest/cite.wasm", + "pin": "site/annotation/guest.mjs", + "as": "cite", + "modules": [ + "PrismAnnotationTable", + "PrismAnnotation", + "Sha256", + "PrismCite" + ], + "dispatch": "PrismCite::prismCiteDispatch", + "vectors": "spec:cite", + "limits": [ + 4096, + 8192, + 8192 + ], + "memory": [ + 256, + 1048576 + ] +} diff --git a/app/specs/guests/annotation/cite.lock.json b/app/specs/guests/annotation/cite.lock.json new file mode 100644 index 00000000..5cfc29f7 --- /dev/null +++ b/app/specs/guests/annotation/cite.lock.json @@ -0,0 +1,4 @@ +{ + "source": "b3663d25a31cff1ff783d5707c14be967bd094c2ee830fa78b5d6ea00b0313f2", + "wasm": "a8ac0cc6e6e19501286a194affea3e2d4bbc218cdef6c439b0368d16ad6afe93" +} diff --git a/app/specs/parts/spec.json b/app/specs/parts/spec.json index e8304461..a69b89c0 100644 --- a/app/specs/parts/spec.json +++ b/app/specs/parts/spec.json @@ -324,6 +324,16 @@ ], "site/emma/guest.mjs": [ "how" + ], + "app/src/PrismCite.lex.tex": [ + "why", + "when", + "how" + ], + "app/src/Sha256.lex.tex": [ + "why", + "when", + "how" ] } } diff --git a/app/specs/standards/register/nist-fips-180-4.json b/app/specs/standards/register/nist-fips-180-4.json new file mode 100644 index 00000000..2b145810 --- /dev/null +++ b/app/specs/standards/register/nist-fips-180-4.json @@ -0,0 +1,13 @@ +{ + "key": "nist-fips-180-4", + "title": "FIPS 180-4 Secure Hash Standard (SHA-256)", + "issuer": "NIST", + "text": null, + "unpinned": "NIST's own SHA-256 test vectors (CAVP short messages and Monte Carlo, app/specs/oracle/nist-cavp-sha256) are hashed by this same module in generators/snapshot (GN-01); the requirement inventory waits on pinning the FIPS text", + "governs": [ + "app/src/Sha256.lex.tex" + ], + "realizedBy": [ + "ST-01" + ] +} diff --git a/app/specs/standards/register/w3c-annotation-model.json b/app/specs/standards/register/w3c-annotation-model.json index 0f80fda4..e5a6dedf 100644 --- a/app/specs/standards/register/w3c-annotation-model.json +++ b/app/specs/standards/register/w3c-annotation-model.json @@ -67,6 +67,7 @@ "governs": [ "app/src/PrismAnnotation.lex.tex", "app/src/PrismAnnotationTable.lex.tex", + "app/src/PrismCite.lex.tex", "site/annotation/guest.mjs" ], "realizedBy": [ diff --git a/app/src/PrismCite.lex.tex b/app/src/PrismCite.lex.tex new file mode 100644 index 00000000..5909ff80 --- /dev/null +++ b/app/src/PrismCite.lex.tex @@ -0,0 +1,197 @@ +\begin{lexlean}{PrismCite} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\useglossary{prism.arch@1.0.0} +\importmodule{Sha256} +\importmodule{PrismAnnotation} +\title{Text application model} +\begin{semanticmodule} +definition{ + name: ciB, + parameters: [s : Bytes, i : Nat], + result: Nat, + body: (match (prim index s i : (Option UInt8)) | Option.none => 0 | Option.some octet => (prim to_nat octet : Nat)), + axioms: [Quot.sound, propext] +} + +definition{ + name: ciIsHex, + parameters: [b : Nat], + result: Bool, + body: (((47 false + | Nat.succ more => (if (n =? 0) then true else (if (ciIsHex (ciB s i)) then (ciHexRun s (i + 1) (prim subtract n 1 : Nat) more) else false))), + axioms: [Quot.sound, propext], + recursive_argument: fuel +} + +definition{ + name: ciAddr, + parameters: [s : Bytes, i : Nat], + result: Bool, + body: (if (((not ((ciB s i) =? 115)) || (not ((ciB s (i + 1)) =? 104))) || ((not ((ciB s (i + 2)) =? 97)) || (not ((ciB s (i + 3)) =? 50)))) then false else (if (((not ((ciB s (i + 4)) =? 53)) || (not ((ciB s (i + 5)) =? 54))) || (not ((ciB s (i + 6)) =? 58))) then false else (ciHexRun s (i + 7) 64 65))), + axioms: [Quot.sound, propext] +} + +definition{ + name: ciDigits, + parameters: [s : Bytes, i : Nat, fuel : Nat], + result: Nat, + body: (match fuel + | Nat.zero => i + | Nat.succ more => (if ((47 acc + | Nat.succ more => (if (e 0x | Option.some part => part) +} + +definition{ + name: ciEscOne, + parameters: [s : Bytes, i : Nat], + result: Bytes, + body: (let b : Nat := (ciB s i); (if (b =? 34) then 0x5c22 else (if (b =? 92) then 0x5c5c else (if (b =? 8) then 0x5c62 else (if (b =? 9) then 0x5c74 else (if (b =? 10) then 0x5c6e else (if (b =? 12) then 0x5c66 else (if (b =? 13) then 0x5c72 else (if (b 0x | Option.some part => part)))))))))), + axioms: [Quot.sound, propext] +} + +definition{ + name: ciEsc, + parameters: [s : Bytes, i : Nat, e : Nat, acc : Bytes, fuel : Nat], + result: Bytes, + body: (match fuel + | Nat.zero => acc + | Nat.succ more => (if (e i + | Nat.succ more => (if (ciIsAddrByte (ciB s i)) then (ciTok s (i + 1) more) else i)), + axioms: [Quot.sound, propext], + recursive_argument: fuel +} + +definition{ + name: ciHead, + parameters: [s : Bytes, a : Nat, ae : Nat, x : Nat, n : Nat], + result: Bytes, + body: (ciCat3 (ciCat3 0x7b2240636f6e74657874223a22687474703a2f2f7777772e77332e6f72672f6e732f616e6e6f2e6a736f6e6c64222c22626f6479223a7b2273656c6563746f72223a7b226578616374223a22 (ciEsc s x (x + n) 0x (n + 1)) 0x222c2274797065223a225465787451756f746553656c6563746f72227d2c22736f75726365223a22) (match (prim slice s a (prim subtract ae a : Nat) : (Option Bytes)) | Option.none => 0x | Option.some part => part) 0x222c2274797065223a2253706563696669635265736f75726365227d2c), + axioms: [Quot.sound, propext] +} + +definition{ + name: ciTail, + parameters: [s : Bytes, ds : Nat, de : Nat, es : Nat, ee : Nat], + result: Bytes, + body: (ciCat3 (ciCat3 0x226d6f7469766174696f6e223a226c696e6b696e67222c22746172676574223a7b2273656c6563746f72223a7b22656e64223a (match (prim slice s es (prim subtract ee es : Nat) : (Option Bytes)) | Option.none => 0x | Option.some part => part) 0x2c227374617274223a) (ciCat3 (match (prim slice s ds (prim subtract de ds : Nat) : (Option Bytes)) | Option.none => 0x | Option.some part => part) 0x2c2274797065223a2254657874506f736974696f6e53656c6563746f72227d2c22736f75726365223a22 (match (prim slice s 0 71 : (Option Bytes)) | Option.none => 0x | Option.some part => part)) 0x222c2274797065223a2253706563696669635265736f75726365227d2c2274797065223a22416e6e6f746174696f6e227d) +} + +definition{ + name: ciJoin, + parameters: [head : Bytes, tail : Bytes], + result: Bytes, + body: (ciCat3 head (ciCat3 0x226964223a227368613235363a (Sha256::sha256Hex (prim append head tail : Bytes)) 0x222c) tail), + axioms: [Quot.sound, propext] +} + +definition{ + name: ciIsOk, + parameters: [r : Bytes], + result: Bool, + body: (((prim length r : Nat) =? 2) && (((ciB r 0) =? 111) && ((ciB r 1) =? 107))), + axioms: [Quot.sound, propext] +} + +definition{ + name: ciJudged, + parameters: [a : Bytes], + result: Bytes, + body: (if (ciIsOk (PrismAnnotation::prismAnnotationDispatch (prim append 0x616e6e6f746174696f6e4d757374730a a : Bytes))) then a else 0x), + axioms: [Quot.sound, propext] +} + +definition{ + name: ciSep, + parameters: [acc : Bytes, a : Bytes], + result: Bytes, + body: (if ((prim length a : Nat) =? 0) then 0x else (if ((prim length acc : Nat) =? 1) then (prim append acc a : Bytes) else (ciCat3 acc 0x2c a))) +} + +definition{ + name: ciItems, + parameters: [s : Bytes, i : Nat, acc : Bytes, fuel : Nat], + result: Bytes, + body: (match fuel + | Nat.zero => 0x + | Nat.succ more => (if ((prim length s : Nat) (0 : UInt64) + | Option.some t => (prim bit_and t (shaMask) : UInt64)), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaShr, + parameters: [x : UInt64, n : UInt32], + result: UInt64, + body: (match (prim shift_right x n : (Option UInt64)) + | Option.none => (0 : UInt64) + | Option.some r => r), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaShl, + parameters: [x : UInt64, n : UInt32], + result: UInt64, + body: (match (prim shift_left x n : (Option UInt64)) + | Option.none => (0 : UInt64) + | Option.some r => (prim bit_and r (shaMask) : UInt64)), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaRotr, + parameters: [x : UInt64, n : UInt32, m : UInt32], + result: UInt64, + body: (prim bit_xor (shaShr x n) (shaShl x m) : UInt64), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaByteWord, + parameters: [s : Bytes, i : Nat], + result: UInt64, + body: (match (Foundation.Bytes::byteAt s i) + | Option.none => (0 : UInt64) + | Option.some b => (prim bit_or (prim bit_or (prim bit_or (prim bit_or (prim bit_or (prim bit_or (prim bit_or (prim bit_or (0 : UInt64) (match (prim equal (prim bit_and b (1 : UInt8) : UInt8) (1 : UInt8) : Bool) + | Bool.false => (0 : UInt64) + | Bool.true => (1 : UInt64)) : UInt64) (match (prim equal (prim bit_and b (2 : UInt8) : UInt8) (2 : UInt8) : Bool) + | Bool.false => (0 : UInt64) + | Bool.true => (2 : UInt64)) : UInt64) (match (prim equal (prim bit_and b (4 : UInt8) : UInt8) (4 : UInt8) : Bool) + | Bool.false => (0 : UInt64) + | Bool.true => (4 : UInt64)) : UInt64) (match (prim equal (prim bit_and b (8 : UInt8) : UInt8) (8 : UInt8) : Bool) + | Bool.false => (0 : UInt64) + | Bool.true => (8 : UInt64)) : UInt64) (match (prim equal (prim bit_and b (16 : UInt8) : UInt8) (16 : UInt8) : Bool) + | Bool.false => (0 : UInt64) + | Bool.true => (16 : UInt64)) : UInt64) (match (prim equal (prim bit_and b (32 : UInt8) : UInt8) (32 : UInt8) : Bool) + | Bool.false => (0 : UInt64) + | Bool.true => (32 : UInt64)) : UInt64) (match (prim equal (prim bit_and b (64 : UInt8) : UInt8) (64 : UInt8) : Bool) + | Bool.false => (0 : UInt64) + | Bool.true => (64 : UInt64)) : UInt64) (match (prim equal (prim bit_and b (128 : UInt8) : UInt8) (128 : UInt8) : Bool) + | Bool.false => (0 : UInt64) + | Bool.true => (128 : UInt64)) : UInt64)), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaWordAt, + parameters: [s : Bytes, i : Nat], + result: UInt64, + body: (prim bit_xor (prim bit_xor (shaShl (shaByteWord s i) (24 : UInt32)) (shaShl (shaByteWord s (i + 1)) (16 : UInt32)) : UInt64) (prim bit_xor (shaShl (shaByteWord s (i + 2)) (8 : UInt32)) (shaByteWord s (i + 3)) : UInt64) : UInt64), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaOctets, + parameters: [], + result: Bytes, + body: 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +} + +definition{ + name: shaOctet, + parameters: [b : Nat], + result: Bytes, + body: (match (Foundation.Bytes::sliceBytes (shaOctets) b 1) + | Option.none => 0x + | Option.some o => o) +} + +definition{ + name: shaNibble, + parameters: [n : Nat], + result: Bytes, + body: (match (Foundation.Bytes::sliceBytes 0x30313233343536373839616263646566 n 1) + | Option.none => 0x + | Option.some o => o) +} + +definition{ + name: shaOctetNat, + parameters: [value : UInt8], + result: Nat, + body: ((((((((0 + (match (prim equal (prim bit_and value (1 : UInt8) : UInt8) (1 : UInt8) : Bool) + | Bool.false => 0 + | Bool.true => 1)) + (match (prim equal (prim bit_and value (2 : UInt8) : UInt8) (2 : UInt8) : Bool) + | Bool.false => 0 + | Bool.true => 2)) + (match (prim equal (prim bit_and value (4 : UInt8) : UInt8) (4 : UInt8) : Bool) + | Bool.false => 0 + | Bool.true => 4)) + (match (prim equal (prim bit_and value (8 : UInt8) : UInt8) (8 : UInt8) : Bool) + | Bool.false => 0 + | Bool.true => 8)) + (match (prim equal (prim bit_and value (16 : UInt8) : UInt8) (16 : UInt8) : Bool) + | Bool.false => 0 + | Bool.true => 16)) + (match (prim equal (prim bit_and value (32 : UInt8) : UInt8) (32 : UInt8) : Bool) + | Bool.false => 0 + | Bool.true => 32)) + (match (prim equal (prim bit_and value (64 : UInt8) : UInt8) (64 : UInt8) : Bool) + | Bool.false => 0 + | Bool.true => 64)) + (match (prim equal (prim bit_and value (128 : UInt8) : UInt8) (128 : UInt8) : Bool) + | Bool.false => 0 + | Bool.true => 128)), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaLow, + parameters: [x : UInt64], + result: Nat, + body: ((((((((0 + (match (prim equal (prim bit_and x (1 : UInt64) : UInt64) (1 : UInt64) : Bool) + | Bool.false => 0 + | Bool.true => 1)) + (match (prim equal (prim bit_and x (2 : UInt64) : UInt64) (2 : UInt64) : Bool) + | Bool.false => 0 + | Bool.true => 2)) + (match (prim equal (prim bit_and x (4 : UInt64) : UInt64) (4 : UInt64) : Bool) + | Bool.false => 0 + | Bool.true => 4)) + (match (prim equal (prim bit_and x (8 : UInt64) : UInt64) (8 : UInt64) : Bool) + | Bool.false => 0 + | Bool.true => 8)) + (match (prim equal (prim bit_and x (16 : UInt64) : UInt64) (16 : UInt64) : Bool) + | Bool.false => 0 + | Bool.true => 16)) + (match (prim equal (prim bit_and x (32 : UInt64) : UInt64) (32 : UInt64) : Bool) + | Bool.false => 0 + | Bool.true => 32)) + (match (prim equal (prim bit_and x (64 : UInt64) : UInt64) (64 : UInt64) : Bool) + | Bool.false => 0 + | Bool.true => 64)) + (match (prim equal (prim bit_and x (128 : UInt64) : UInt64) (128 : UInt64) : Bool) + | Bool.false => 0 + | Bool.true => 128)), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaWordBytes, + parameters: [x : UInt64], + result: Bytes, + body: (Foundation.Bytes::appendBytes (Foundation.Bytes::appendBytes (shaOctet (shaLow (shaShr x (24 : UInt32)))) (shaOctet (shaLow (shaShr x (16 : UInt32))))) (Foundation.Bytes::appendBytes (shaOctet (shaLow (shaShr x (8 : UInt32)))) (shaOctet (shaLow x)))), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaNatBe, + parameters: [x : Nat, width : Nat, acc : Bytes], + result: Bytes, + body: (match width + | Nat.zero => acc + | Nat.succ rest => (shaNatBe (prim quotient x 256 0 : Nat) rest (Foundation.Bytes::appendBytes (shaOctet (prim remainder x 256 0 : Nat)) acc))), + recursive_argument: width +} + +definition{ + name: shaK, + parameters: [], + result: Bytes, + body: 0x428a2f9871374491b5c0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a7914706ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e92722c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636f84c878148cc7020890befffaa4506cebbef9a3f7c67178f2 +} + +definition{ + name: shaZeros, + parameters: [n : Nat, acc : Bytes], + result: Bytes, + body: (match n + | Nat.zero => acc + | Nat.succ rest => (shaZeros rest (Foundation.Bytes::appendBytes acc 0x00))), + recursive_argument: n +} + +definition{ + name: shaPadded, + parameters: [m : Bytes], + result: Bytes, + body: (let n : Nat := (Foundation.Bytes::byteLength m); (let r : Nat := (prim remainder (n + 9) 64 0 : Nat); (let k : Nat := (if (r =? 0) then 0 else (prim subtract 64 r : Nat)); (Foundation.Bytes::appendBytes (Foundation.Bytes::appendBytes (Foundation.Bytes::appendBytes m 0x80) (shaZeros k 0x)) (shaNatBe (prim multiply n 8 : Nat) 8 0x))))) +} + +definition{ + name: shaSchedule, + parameters: [block : Bytes, t : Nat, w : Bytes, fuel : Nat], + result: Bytes, + body: (match fuel + | Nat.zero => w + | Nat.succ rest => (if (63 0x + | Nat.succ rest => (if (63 0x + | Nat.succ rest => (if (7 state + | Nat.succ rest => (match (Foundation.Bytes::sliceBytes m i 64) + | Option.none => state + | Option.some block => (let w : Bytes := (shaSchedule block 0 0x 64); (let out : Bytes := (shaRounds w 0 (shaWordAt state 0) (shaWordAt state 4) (shaWordAt state 8) (shaWordAt state 12) (shaWordAt state 16) (shaWordAt state 20) (shaWordAt state 24) (shaWordAt state 28) 65); (shaBlocks m (i + 64) (shaMix state out 0 8) rest))))), + axioms: [Quot.sound, propext], + recursive_argument: fuel +} + +definition{ + name: sha256, + parameters: [m : Bytes], + result: Bytes, + body: (let p : Bytes := (shaPadded m); (shaBlocks p 0 0x6a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19 ((prim quotient (Foundation.Bytes::byteLength p) 64 0 : Nat) + 1))), + axioms: [Quot.sound, propext] +} + +definition{ + name: shaHexFrom, + parameters: [dg : Bytes, i : Nat, n : Nat, acc : Bytes], + result: Bytes, + body: (match n + | Nat.zero => acc + | Nat.succ rest => (let b : Nat := (match (Foundation.Bytes::byteAt dg i) + | Option.none => 0 + | Option.some o => (shaOctetNat o)); (shaHexFrom dg (i + 1) rest (Foundation.Bytes::appendBytes acc (Foundation.Bytes::appendBytes (shaNibble (prim quotient b 16 0 : Nat)) (shaNibble (prim remainder b 16 0 : Nat))))))), + axioms: [Quot.sound, propext], + recursive_argument: n +} + +definition{ + name: sha256Hex, + parameters: [m : Bytes], + result: Bytes, + body: (let dg : Bytes := (sha256 m); (shaHexFrom dg 0 (Foundation.Bytes::byteLength dg) 0x)), + axioms: [Quot.sound, propext] +} +\end{semanticmodule} +\end{lexlean} diff --git a/site/annotation/guest.mjs b/site/annotation/guest.mjs index 5348e795..ce84ab6a 100644 --- a/site/annotation/guest.mjs +++ b/site/annotation/guest.mjs @@ -1,10 +1,13 @@ // Generated by generators/guests from app/specs/guests (GU-01): the standalone -// guest of PrismAnnotationTable, PrismAnnotation, built by tools/guests/build.sh from the modules the +// guests of PrismAnnotationTable, PrismAnnotation, PrismAnnotationTable, PrismAnnotation, Sha256, PrismCite, built by tools/guests/build.sh from the modules the // Prism compiles, so the Node suites run every request without the holo. Each // exports holo_alloc(len) and holo_run(ptr, len) -> (outPtr << 32 | outLen); // bytes whose SHA-256 is not the pinned one are refused before they compile. -export const GUEST = { path: 'guest/annotation.wasm', sha256: '87c2f80c684f232e39bc5bee7654c08a367ab1fd8dd370b6a589a36a9501848b' }; +export const GUESTS = { + judge: { path: 'guest/annotation.wasm', sha256: '87c2f80c684f232e39bc5bee7654c08a367ab1fd8dd370b6a589a36a9501848b' }, + cite: { path: 'guest/cite.wasm', sha256: 'a8ac0cc6e6e19501286a194affea3e2d4bbc218cdef6c439b0368d16ad6afe93' }, +}; const hex = (u8) => Array.from(u8, (b) => b.toString(16).padStart(2, '0')).join(''); const encoder = new TextEncoder(); diff --git a/site/annotation/guest/cite.wasm b/site/annotation/guest/cite.wasm new file mode 100644 index 00000000..30b6779c Binary files /dev/null and b/site/annotation/guest/cite.wasm differ diff --git a/test/parts/parts.txt b/test/parts/parts.txt index 60106f30..a64fd3a2 100644 --- a/test/parts/parts.txt +++ b/test/parts/parts.txt @@ -27,6 +27,7 @@ app/src/PrismBrowser.lex.tex app/src/PrismBrowserProofs.lex.tex app/src/PrismChronology.lex.tex app/src/PrismChronologyProofs.lex.tex +app/src/PrismCite.lex.tex app/src/PrismCurate.lex.tex app/src/PrismCurateProofs.lex.tex app/src/PrismDest.lex.tex @@ -82,6 +83,7 @@ app/src/PropertyProofs.lex.tex app/src/Quality.lex.tex app/src/RoutingProofs.lex.tex app/src/Security.lex.tex +app/src/Sha256.lex.tex app/src/VocabProofs.lex.tex site/annotation/guest.mjs site/app.mjs