Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yannivain committed Mar 28, 2022
2 parents 3952f2f + 499c751 commit ff1c5ed
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
34 changes: 33 additions & 1 deletion README.md
@@ -1,2 +1,34 @@
# Digital-Notarial-Deed
Open-Legal-Lab challenge #12 "Digitale Notarielle Urkunde"
Open-Legal-Lab challenge #12 "Digitale Notarielle Urkunde".
- Open Legal Lab Hackathon: https://opendata.ch/events/open-legal-lab-2022/
- Challenge: https://challenges.openlegallab.ch/project/49

## Context and challenge
In Switzerland, the notaries are currently using Paper for the contracts about public deeds.
It makes the process manual and complicated as it involves printing, signing, scanning manually write the information into the registry.

The goal of this hackathon is to define a format that would make the process fully digital.
We designed a prototype of an XML structure to store the contract.
The main requirements are that the contract should be signed and easily computer and human readable.

The XML is generated and signed through an online formular.

To visualize a "pretty" version of the contract, a XSL template has been created that generate a webpage containing the contract informations.

## Run the web application
Prerequesites: Node & npm
```text
git clone https://github.com/yannivain/digital-notarial-deed.git
cd digital-notarial-deed/app
npm install
npm run serve
```
Go to http://localhost:8080/

## Visualize the XML contract
Prerequesites: Java
```text
cd visu
java -jar xslt-1.1.0.jar <Link to your XML contract> template.xsl visualization.html
```
Open the HTML into your browser.
33 changes: 11 additions & 22 deletions app/src/components/DocumentCreationSteps.vue
Expand Up @@ -164,15 +164,15 @@ import NotaryForm from "@/components/NotaryForm"
import SpecialConditionForm from "@/components/SpecialCondition"
import DocumentDocument from "@/data-classes/DocumentDocument";
import {downloadXml} from "@/xml/utils";
import document from "@/components/demo.json";
import demoDocument from "@/components/demo.json";
import {SignedXml} from "xadesjs";
export default {
name: 'DocumentCreationSteps',
components: {SpecialConditionForm, NotaryForm, PriceForm, LotForm, PersonForm},
data: () => ({
step: 1,
document: cloneDeep(document),
document: cloneDeep(demoDocument),
// document: {
// seller: cloneDeep(DEFAULT_NATURAL),
// buyer: cloneDeep(DEFAULT_NATURAL),
Expand Down Expand Up @@ -218,16 +218,13 @@ export default {
xmlDoc.appendChild(xmlRoot)
this.importPrivateKey(this.privateKey)
.then(cryptoKey => {
console.log(cryptoKey)
const signedXml = new SignedXml()
return signedXml.Sign({name: "ECDSA"}, cryptoKey, xmlDoc)
})
.then(signedDocument => {
console.log(signedDocument)
downloadXml(signedDocument, 'real_estate_contract.xml')
.then(cryptoKey => new SignedXml().Sign({name: 'RSA-PSS'}, cryptoKey, xmlDoc))
.then(signature => {
const signatureElement = new DOMParser()
.parseFromString(signature.toString(), 'text/xml')
.documentElement
xmlRoot.appendChild(signatureElement)
downloadXml(xmlDoc, 'real_estate_contract.xml')
})
.catch(err => {
console.error(err)
Expand All @@ -238,18 +235,10 @@ export default {
const fileReader = new FileReader()
fileReader.onload = resolve
fileReader.onerror = reject
fileReader.readAsText(file)
fileReader.readAsArrayBuffer(file)
})
.then(loadEvent => {
const keyText = loadEvent.target.result
const header = '-----BEGIN PRIVATE KEY-----'
const footer = '-----END PRIVATE KEY-----'
const cleanedKeyText = keyText.substring(header.length + 1, keyText.length - footer.length - 1)
const cleanedKeyArrayBuffer = new TextEncoder().encode(cleanedKeyText)
return crypto.subtle.importKey('pkcs8', cleanedKeyArrayBuffer, {
return crypto.subtle.importKey('pkcs8', loadEvent.target.result, {
name: 'RSA-PSS',
hash: 'SHA-256'
}, false, ['sign'])
Expand Down

0 comments on commit ff1c5ed

Please sign in to comment.