# Creating a uncopyable physical key

In many stories, a mysterious indent in a wall acts as a lock to a secret vault full of ancient treasures. The way to unlock this archaic door? A strangely shaped stone. By placing it into the indent, the vault opens.

Unfortunately, this idea ran into a problem when I was trying to adapt it for my world. It isn't that magic can't be used to activate the mechanism, as this ancient civilisation was one comprised of powerful mages. They could easily make a lock fulfilling all the criteria here... except that something the same shape as the indent would still open it. That' my problem - the issue arises in trying to make the lock secure.

Whenever I see an example of this idea, I always think to myself 'why didn't someone get curious and make something the same shape of the indent to 1) see what happened, if anything; or 2) fill in the gap and make the wall look better?'

So to put it simply: How, without using magic, could a lock of this type be made secure to counterfeit keys?

I say without magic for two reasons. Mostly, because it's more interesting. But partially because I can imagine a location as important as an ancient temple being protected from magic to counter vandals. The lock system itself uses magic to recognise when something of the right shape has been inserted. However, the key itself cannot have runes or anything magic to identify it.

What I'm looking for is a way to make this lock 'immune' by counterfeit keys without using magic. I've considered having the key made of a special material, but then I'm not sure how to make 1) the lock recognise the material without the use of the minor magic explained above; and 2) the lock needs to be 'immune', for want of a better word, to a different key of the same material.

EDIT: further information on request. The civilisation's magic does all the normal magic things (beams of light, fire, etc) and can react differently in certain situations (in light or dark, hot or cold, touched or not). Their technology level and culture in general is similar to that of the ancient Egyptians except for metalwork, which has developed to a renaissance level of precision due to extremely powerful catalysts being available to stoke the fires. They have no way to determine DNA / blood type, but could determine weight or size using the simple magic explained in the lock. The temple is made of a sandstone-type material, all marked with runes to stop decay or destruction. The modern era has no way to bypass these runes - to access the vault, they'll need to go through the lock.

A further explanation on the lock: the lock itself is protected from damage like the rest of the temple. However, it can contain runes to detect light, weight, size - any simple measurement. (Of course, any answers that they couldn't detect, such as radiation, are always interesting and just as appreciated!) The key cannot contain magical properties of any sort, but can be made of magnetic metals, crystals, stone, or any other such material. Furthermore, as the society has a far deeper understanding of metals than other materials, they can create more sophisticated metalwork than masonry or ceramics. Once the lock has been opened, a signal will be sent to the door, triggering runes that break down the stone. In addition, it will also disable the decay runes, allowing the temple to fall apart in years to come. The civilisation built the temple in the final years before they were invaded and massacred. Its aim was to preserve its contents until a successor obtained the key from somewhere and unlocked the vault.

The unlockers are at pretty much our tech level minus 20 years, except for computing.... If they had atom perfect recreation, they could copy the key no matter what we did! They're sure magic existed, but can't prove it scientifically or use it. In reality, they DO have all the time in the world to get into this vault... but really want to do it before our 20-year old researchers grow senile and die.

Oh, and security by obscurity is not security. It can go in addition to strong security and further its strength, but 8 million key holes with a regular key isn't really an answer.

I would have added this originally, but I wasn't sure how important materials and such were. Anyway, it's here now!

• Comments are not for extended discussion; this conversation has been moved to chat. – Monica Cellio May 1 '17 at 1:02
• Probably not enough for an answer but - if they were good with metal and the stone could be magnetized, maybe it required something akin to a modern magnetic security badge? I think after all those years it'd be plausible that the reader would no longer be working, no longer be magnetized, and therefore just not work. – Michael May 2 '17 at 1:48
• They claim to have developed an uncopyable key: urbanalps.com/en You may find some inspiration there. – James May 2 '17 at 8:39
• Just two comments. 1) pay attention to using the weight: the key can lose some during the centuries or be damaged in a small way.. 2) the most trivial way to protect against brute force attacks is the lockout mechanism. If an attacker tries to input your password for N times it cannot input it again for X seconds. You can implement a similar protection: if the key is wrong the temple doors shut for a month: short enough to allow for a second try in a short time, but long enough to discourage brute force attacks – frarugi87 May 2 '17 at 9:16
• en.wikipedia.org/wiki/Physical_Unclonable_Function – k-l May 2 '17 at 17:54

As any good locksmith will tell you, any lock anywhere can be fooled. Not all of them can be picked with a bump set, but they can be accessed, one way or another.

There's nothing that it would be IMPOSSIBLE to copy. Just more difficult.

Let's go about making it more difficult though.

First, make the number of planes/requirements higher for the unlock. So your standard key is flat on the bottom with grooves on the top.

Those grooves tell the lock that the key is valid. Harder to pick locks have grooves on booth sides.

Still harder are the quad keys that have ridges not just on the top and bottom, but on or along the sides.

There's also the Chain Key, which uses those principles as well. See the link for more on how it works, but basically, it uses the fact that it's FLEXIBLE to foil most lock pickers.

All right, so what we've learned about keys and locks is this: The more requirements needed to open the lock, the less likely that lock is to be picked. So when it comes to a physical object as a key, you'll want to look at EVERYTHING--like the composition of the object--is it a special kind of crystal that refracts light a certain way? Have that be one requirement. And yes, that can be physical and set off a rube goldberg type thing, maybe.

The weight, specific dimensions on all sizes, perhaps even the AGE, density, or composition can all be physical factors leading to the unlocking of the lock. Perhaps the lock checks for density, and the center of the key object is hollow in a specific shape that it checks for somehow.

Nothing is IMPOSSIBLE to copy. All you can do is make it more difficult. EDIT: This answer takes into account more primitive tech since you said ancient, so I didn't include a scanner for radioactivity, (which KUDOS to that poster, that's a fabulous idea). But still, they could be so ancient they are advanced. My ideas are definitely a stretch for primitive people as well.

EDIT: So now I have to add something about the design of the lock, which can be magic, though the key must be mundane, according to the poster.

The lock system itself uses magic to recognise when something of the right shape has been inserted. However, the key itself cannot have runes or anything magic to identify it.

To make it less likely to be picked, (or at least take longer) even with magic, have it work like this: purely physical part of the lock uses the weight and grooves to "wake up" the first magical scanner, which hits the crystal portion of the key with light. The correct refraction triggers the second magical scanner, which looks for a hollow in the center of the object, of a particular shape. This triggers the next scan which could check for the age of the object, or stealing from the AndyD273, a series of scans which check for various isotope levels on different parts of the object. But, while all this is going on, all of the other scans are still in progress--the initial scan triggers the next, BUT, if any of the other scans "go away" or aren't there anymore, the whole thing shuts down. (for a magic user, this will mean that they will have to keep spoofing the crystal, and the hollow, while trying to spoof the next series). All together, this is one lock that would be very difficult to pick or spoof.

• Eh, you could probably have magic be able to detect radioactivity, or something similar. Crystal vibrations is something established in magic and science – AndyD273 Apr 28 '17 at 18:55
• You could also have magic encode an asymmetric key pair and have one of the keys in the physical keystone itself. The lock system could then magically encrypt a random string using the other key from the pair and expect the keystone to decrypt the string. And by magic I mean a computer. – Kyle Apr 28 '17 at 21:11
• "Nothing is IMPOSSIBLE to copy" quantum mechanics begs the differ. – Maciej Piechotka Apr 28 '17 at 22:05
• @ErinThursby you cannot duplicate state but you can move. State does not change - I'm not sure what you mean by "changes from moment to moment" or "inverse of quantum" - state does not change from moment to moment unless it interacts wi. Also if you do know it or at least base of state beforehand you can measure it without destruction - the prohibition is on arbitrary state you don't know. With regards to appearing as mundane - I guess it depends how you interpret the question. – Maciej Piechotka Apr 28 '17 at 22:56
• @MaciejPiechotka The no-cloning theorem is a current QM theorem, yes. However, it is not very effective for keys. The act of measuring the state of the key (i.e. figuring out if you have the right key inserted) destroys the information so the key cannot be used twice. However, that can sometimes be enough. In quantum encryption, that is exactly the process they use. They effectively send a string of keys, and destroy half of them in the process. – Cort Ammon Apr 29 '17 at 15:41

Two-Factor Authentication! Can you broaden your acceptable answer to allow the key to be combined with something else? For example:

• The lock requires the physical key plus exactly one drop of blood placed on the tip. Perhaps it has to be a female goat's blood or something specific.

• The lock requires that the key be inserted into the lock at a particular time of day, or day of the year, or when the sun is shining (or not).

• The lock requires the key to be inserted and turned exactly 1/4 to the left before being removed.

• There are 32 indentations into which the key fits. You must insert it into a specific one. This one may depend on the day of the year or the hour of the day.

• Besides the key, there is a floor pressure plate beneath the lock which weighs you, and you must weigh exactly 195 pounds when you insert the key for the lock to open. (Which is heavy for the era, which means you plus some sandbags on your shoulders.)

That's how modern two-factor authentication works: one thing you know and one thing you have with you. So your password can be compromised, but that's not enough. In like manner, your key could be duplicated, but it's the key plus how to use the key that matters.

The details of the extra information you must have would determine what happens if you are wrong. For the blood, having no blood or the wrong blood simply does nothing. The key appears worthless. Same for the time of day or the 1/4 turn.

For the 32 indentations, you'd have to do something more severe to avoid them trying each indentation in turn: things like poison gasses, flames, crushing rocks, etc. Or maybe the use of the wrong hole locks things up permanently, or forces you to know the "reset" hole that will reset the lock so you can then try a different hole. (In the extreme case, the key could be required to be inserted into the 32 holes in a prescribed sequence or it would not work -- like a combination lock with the addition of a key.)

• +1 This comes closest to answering the question. As many other answers have pointed out, a simple shape will always be possible to duplicate, but they have all then gone on to show ways of making the duplication more complex. Follow the mantra "security by obscurity is not security". 2FA is definitely the way forward and this is the best answer which covers it adequately – Darren H Apr 28 '17 at 22:27
• An excellent example (though requiring some change for the whole "magic lock but no magic in key" thing) is the final action scene in The Fifth Element: both the key corresponding to an element and that element itself must be present. – Nij Apr 29 '17 at 0:05
• "Stand by the gray stone when the thrush knocks on the last light of Durin's day"... – mattdm Apr 30 '17 at 8:53
• Yup, look at network/computer security - something you have, and something you know. Make it more complex, and have it only work when applied in a certain way, or only available to be seen/accessed to unlock it at certain times (like the back door to smaug's layer in the hobbit like mattdm says) – ivanivan Apr 30 '17 at 14:55
• If you want it more secure as well, you could use more than 2FA, and opt instead for 10FA, or more. In fact, doing so might even create a McGuffin for your characters to research, find, and gather all of the pieces of the puzzle. – Anoplexian - Reinstate Monica May 1 '17 at 14:34

Too many answers with "uncopyable key is impossible" advises, so I have to stand up.

There is no need to jump directly to quantum magic to argue and show that to replicate a quantum system one has to measure it and thus destroy superpositions of states which it naturally have and which may be the key by complementing with another quantum system and by measuring them both produce a signal to open the thing. And closing would look like creating a new matching state for key and the lock.

No, there are other things which are hard to replicate and relatively easy to detect, and magicians use them all the time.

It has so happened that I have broken into one of their vaults to find the place with those strangely shaped keys they make there. There is the picture of their secretsecretsecret

It is not coincidence that magicians love to use crystals, especially diamonds (because it cuts steel very well, and makes super durable tools, they are best man's friends)

Natural diamond have small imperfections in the structure (on the level of single atoms), even if it looks like a perfect stone, which are observable via effects like different light polarization.

Both of those imperfections inclusions and stresses can be observable with light and with sound, and probably they could be detected with electricity(like crystal oscillators used in electronics)

• have read that one lab which makes scalpels blades and such from diamonds(which is actually a tricky form to make from a diamond), by using ultrasound, uses ultrasound to relieve stress in diamond structure too, thus making them stronger. I guess those stress pictures might be also created in a similar way.

It depends on the technology which is used to identify the crystals starting from confirming that it is a diamond(by squeezing it in the keyhole, as an example(A very large diamond might be one of it's kind)), ending by observing imperfections caused by small groups of atoms.

There is so called Photoelasticity, and funny practical demonstration with commonly available objects https://www.youtube.com/watch?v=dZaqY2vyeNo

Same thing will be unique and individual for each crystal out of the box, there is not need to create it, it needs just to be tested and as you might see it does not require super equipment to do so. But it will be very hard if even possible to replicate it even if you have perfectly fast working tunnel microscope which is capable of manipulating with the key material atom by atom. (I doubt it will help, needs something which can make true snapshot of the structure all at once)

So, magical crystals aren't that magical, but they have unique and useful properties, which can be exploited to be a key even at low tech level.

It can contain 0 electronics, 0 magic, and be pure mechanics like Rube Goldberg machine working solely on the light. (so yes the lock can be coded to opened at certain moon/sun angle, or at certain date, be opened only once etc)

A Cody's lab video contains almost all necessary elements to do so Sprengel Vacuum Pump: The most efficient pump ever? (a bit long but worth to watch)
Add mirrors, prisms(for different incoming light spectrum, and for detection of resulting light spectrums by directing them to the needed angle), add polarisation filters(some crystals have natural properties), add more of those rotating thingies, tune them to be in resonance, drill bunch of holes in lock for light to interact in the crystal and generate proper combination of results which will begin the chain reaction, etc etc.

Creating such lock for partcular key and particular environment in particular place, or better say creating the plan for its creation might require very strong magic of Intel Xeon over 9000 crystal power with GPU's from Nvidia magician and more you spend of that while creating the plan for the system harder it will be for you potential enemies to crack it, same as with bitcoins system you has to have more power than half of the system to compromise it, but in the case one who would to compromise the lock system has to have way more power and skills than those who have created it.

N.B. Do not forget to check that you have strong walls, so it worth to have such lock.
N.N.B. And yes, you create lock for the key, not key for the lock

A bit of clarification, an answer to @Schwern comment

No it should not be summed as just look at small imperfections. It's a range starting from a just macro object with certain properties to single atom imperfection in the crystal structure. Which level it takes depend on technologies available for lock builders and how and which parameters they would like to measure. In fact, it is a combination of steganography, secure decrypting algorithm, and open key systems. Also, it seems you imagine the lock as usual door lock, which might be not the case, especially on low tech level as it might require a significant amount of light to work, long distances to precisely measuring light refraction angles, and system which feed the key with particular wavelengths etc. It's more like a cave which you would expect to have in a magic setting. A significantly big structure, which makes the work, if it gets right signals, where the key is a cryptographical algorithm which complements the system algorithm. I had thoughts to describe the possible mechanism more detailed, but realizations can be very much different and describing from the idea to working mechanism too long and not necessary needed for OP. Using physical object as cryptographic keys is real deal, you can read a randomly picked pdf about that http://ceu.archives.ceu.hu/archive/00001003/01/francia.pdf . If one can create a snapshot on the atomic level, without disassembling the key - yes, the key can be copied, but if not then you can have a key which can't be copied, it is not necessary any key. At our current technological level, any diamond can be used as the key which can't be copied.

• I like the general solution. The information held by the key is in plain sight, but the act of trying to make a copy of it is beyond the technology available at the time. It reminds me greatly of biometrics. All biometric data can be easily copied, but creating a fake "key" with that copied data can be quite difficult, or even impossible! – Cort Ammon Apr 29 '17 at 15:44
• This appears to be just another hard to copy key, so I DV'd for the opening assertion, but I'm having a hard time following what's going on. I believe it can be summed up as "look at the microscopic imperfections in a crystal". Indeed, that would require very specialized equipment to replicate. But when you have a lock that complicated, delicate, and fragile you'd attack the lock. I don't mean bashing it with a hammer, though that might work, I mean messing with how it measures the key. – Schwern Apr 30 '17 at 18:29
• @CortAmmon Biometrics are very easy to fake. The problem is not just in the key (the key is a problem since you carry it openly everywhere and it can't be changed) but also in the lock. The key isn't your actual biometrics, but a simplified representation that can be faked. This is a common theme in designing locks: make it too precise (either physical tolerances or scanning accuracy) and the lock won't work reliably. Make it too loose and you can take advantage of that to fake the key or pick the lock. – Schwern Apr 30 '17 at 18:32
• @Schwern added small clarification/response to your comment. Good point about accuracy though. I do not say my idea is perfect, I wonder how that magician could keep dust free environment without magic during millennia I guess, the main idea was to show that copy resistant key is easier than a quantum magic, or any type of magic, including clark magic – MolbOrg Apr 30 '17 at 19:15
• To build on this slightly... different materials are transparent to different wavelengths of light. To protect both the key and keyhole from damage which would prevent them from successfully being used together in the future, as well as hide the mechanism for how the lock works: Encase each in a material that is transparent to the light being used. In the end the key looks like a simple stone rod and it is just slid into a smooth hole in the wall. – Mr.Mindor May 1 '17 at 18:52

Since this is going to be non-magical and ancient you could try something like magnetism. Use a specific alloy of iron and rare earth magnet to get the magnet/key to a specific strength of magnet. Design the lock to respond to that level of magnetism with a very delicate mechanism. Too much or too little magnetism won't be able to open the lock.

You could even get creative with making the alloy so that different parts have different magnetic strength (maybe, I'm kind of spitballing, but it sounds plausible). that way, not only would someone have to figure out the content of the alloy, they would also have to cast it perfectly.

It's not impossible to duplicate, but it sure wouldn't be easy.

• IMHO, this approach is more feasible than radiation, unless you have a very high tech level in your world. – Catalyst Apr 28 '17 at 22:17
• Your spitballing idea was what I was thinking as well. It doesn't have to be complicated: Bake a piece of clay with various strength magnets in various places on the inside. – Carl Apr 29 '17 at 5:11
• you could also monkey with which way the magnets are facing, changing the polarity of the magnets. That way, iron filings might give someone the locations of the magnets, and maybe the strength, but it would take several tries to figure out the North South polarity of each one. Also, make sure to destroy all records of the key's manufacture after it's creation. – Paul TIKI -Monica come Home Apr 29 '17 at 5:23
• I like the idea of an alloy because there are different techniques in making them. some are extremely well blended, others not so much. by adding random swirls of the rare earth and then covering the entire thing in a non magnetic metal, it would be very hard indeed to figure out how it was done. Someone might guess that the magnetic properties were important, but then they would have to figure out the distribution of the rare earth in the alloy, along with the polarity. Not impossible, but darn hard without damaging the original key. – Paul TIKI -Monica come Home Apr 29 '17 at 5:32
• My niece has a puzzle box that works on a similar principal. It has magnets that pull bolts into notches in the lid. You bang it on the table and they rattle down away from the lid and you can slide it sideways. Choosing the right shape with magnets in the right places seems to meet all criteria. You could even add extra security to it by having dummy bolts that lock the lock if magnets are applied to other places in the shape. – Myles May 2 '17 at 19:48

Take a piece of glass or a precious stone and break it in two. You will get a unique fracture. One part stays inside the lock and the other is the key. Only the two parts will fit together correctly. It is impossible to make an accurate copy of the fractured stone, especially in the ceramic material. This is pretty much true even in the present day.

As for detecting the correct fit, only when the two pieces fit together correctly will light shine through them without being deflected. Any imperfection in fit will cause light to be scattered in other directions. Another thing that can happen with perfectly matched pieces of broken glass is that they can be held together when wet by the surface tension of water - this doesn't work if they don't match perfectly.

If you're using magic or handwavy type detection, you could also consider the added security of a marbled material, where matching the veins of different composition in the material makes it even more difficult to copy.

• +1, I wanted to post an answer based on that principle myself. What you need is to simply lack the technology to create the key in a controlled way - you have to create the original by a process with sufficient randomness, and then you cannot replicate it by repeating the process. – rumtscho Apr 30 '17 at 18:15
• One thing to note is that this makes both key and lock susceptible to wear and tear. This means that the key is not usable infinitely long, because either the lock or the key will end up being deformed by erosion/abrasion/rough treatment over time, and at one point there will be too much of a difference to make it work. – Nzall May 2 '17 at 9:00

Yes, it is possible. Using quantum entanglement with one entangled particle in the lock and the other in the key. When the key is inserted into the lock, the lock can observe both particles in real-time.
Proving that this particular key is correct for this particular lock involves watching both particles as they cascade through various states in perfect synchronization. If they stay in sync for an adequate length of time to rule out random chance (say 24 hours), then the lock opens.

• You have just as well said "quantum magic". – Shufflepants Apr 28 '17 at 19:57
• That's not how quantum entanglement works. – celtschk Apr 28 '17 at 21:10
• @celtschk While description is... incorrect I think that having a pairs of entangled particles would solve the problem. For example if particle is |++> = (|00> + |11>)sqrt(1/2) and we select base of 01 then we would always get either 0 or 1 on both. However the process would destroy both the key and the lock each time which may be problematic. – Maciej Piechotka Apr 28 '17 at 22:27
• @MaciejPiechotka: Yes, you could basically store a large number of entangled pairs and then do Bell tests on them. But that's not what the answer describes. The idea that entangled particles "stay in sync" is already wrong (they "stay in sync" in exactly the same situation in which non-entangled particles "stay in sync", namely when they stay unchanged; note that there are changes that do not change the entanglement, but do change the state of the particles relative to each other). And the second problem is that you cannot observe the entangled quantities without destroying the entanglement. – celtschk Apr 29 '17 at 5:55
• It is true that popular-science descriptions are often misleading. And I'm possibly over-sensitive on it given that I'm actually working in that field. On the other hand, I guess the fraction of readers who'd see the problem in it is significantly higher in Science Fiction than is on the general population. – celtschk Apr 29 '17 at 15:23

We have this kind of key in real life, today, if you broaden your view. I'm talking about ATM cards.

The trick here is that the shape is basically meaningless. Whats securing the "lock" is the information in the key. The chip on the card provides a key thats crpythographically secured, and the lock only responds to the correct key.

The correct key cannot be deduced from the shape of the lock, the only way to produce a correct key is either having the original key, or lacking that, trial and error. Make the key large enough and trail and error becomes infeasible. Of course, if you had access to the original key, cloning it is still possible with the right technology.

Tricking the lock without ever having seen the key on the other hand will be impossible. This is in principle not so much different from a mechanical lock, only the lock does provide strictly only one single feedback to the burglar: wrong or correct, where a mechanical lock does provide this feedback for every lock cylinder (think of the trope where the master thief "hears" the lock clicking when trying to pick it).

• Right, but this kind of encryption on the key itself, at this level, would probably be magic in nature, since the parameters were that the key be entirely physical and the lock be magical to scan. Unless the feedback came from the object's specific resonance or something? I don't know how much science/tech we can use here, otherwise a chip or encryption would be the way to go. – Erin Thursby Apr 28 '17 at 20:48
• Well, I'd say this depends mostly on the TC's imagination how to best implement the principle into his world. You could simply encode the information as a series of indentations in the key and check for that complex key shape with magic. The whole trick is the shape of the keyhole being a red herring and the lock providing only single feedback, revealing no clues about the correct key. – Durandal Apr 28 '17 at 20:54
• Couldn't you just copy the indentations? Just make a cast of it? It really could be reading anything about the object though, not just indents. – Erin Thursby Apr 28 '17 at 21:30
• To make a cast of the key, you'd first need to have that key. If you have the key, you don't need a copy. I clearly stated "cloning it is still possible with the right technology". I don't even see that as an issue, the TC wrote "uncopyable" in the title, but his questions issue clearly can be solved without an unclonable key. – Durandal Apr 30 '17 at 17:04

I don't know if you consider this physical "enough", but a flat hologram cannot be copied in normal ways. In other words, you can't just make a photocopy of it with a photocopier.

The hologram, like the one you see on expensive event tickets or credit cards, is three-dimensional information encoded in a 2-dimensional surface. Amazingly, when you turn a hologram, you literally see different parts of the image, depending on the angle you tilt it at. As this flat hologram rotates, you see different sides of the building, as if it were three-dimensional. But it's just a flat, 2-D hologram.

The hologram is made through the interference of two patterns. They combine to create the image that you see.

To copy the hologram, you need the two original sources. If you put a hologram on a photocopy machine, you just get an image of the hologram from one angle, and not all of the 3-D information contained within the hologram.

To have a complete copy of the hologram, you need the two original sources used to make it. You can't derive that information from an existing hologram.

That's why they put holograms on concert tickets and credit cards--they can't be copied. If you put your credit card or concert ticket on a photocopy machine, flatbed scanner, or just take a picture, you get just a 2-D "snapshot" of the hologram from a single 2-D perspective, not a replication of the 3-D hologram.

So, the hologram has a physical component, but the uniqueness of it is the encoded 3-D surface on it. If you carried around a little plate with a hologram on it, nobody could copy the hologram just by coming into possession of your plate. They'd need the two sources used originally to make the plate you carry.

As to how your lock "reads" the holographic key, it would have to have a light-sensing component.

• You could "just" photocopy from more than one angle, reconstruct the two source images then create a new hologram. The angled photocopying could be done by tilting the camera / strip light in an actual photocopier. However, you need quite advanced tech to make a hologram in the first place. – wizzwizz4 Apr 29 '17 at 9:28
• Yes, but if the lock checks and angle you didn't photography, your key wouldn't work. – user151841 May 1 '17 at 2:20
• "They'd need the two sources"... "reconstruct the two source images"..."your key wouldn't work". A contradiction, unless you're saying that you can't reconstruct the two source images (which may require more than two angles, but I don't see why it should be impossible with a finite number of angles). – wizzwizz4 May 1 '17 at 8:19
• It depends on the resolution of the sensor, and what exactly it's checking. Suppose you take 8 pictures, each at 45 * rotations. Suppose the lock is checking for part of the hologram that can only be seen at 30 *. Your hologram doesn't have that information. Perhaps to help understand, have a look at the video I linked and figure out how many images exactly you would need to re-create the entire thing. If there is someone you can see at one angle that you don't capture in your set of 2-D snapshots, you don't have that information, and if the lock is checking for it, it won't be there. – user151841 May 1 '17 at 18:13
• It seems to me as if there may be more than two source images in that hologram... – wizzwizz4 May 2 '17 at 6:27

# You don't need to copy the key to open the lock.

Let's talk about the underlying assumption of the question: that you need to copy the key to open the lock. You don't. In circumventing security, rarely do you go after the security itself, but around it. If you make an incredibly difficult to copy key, attack the lock, the locking mechanism itself (like opening a door with a credit card), or the door, or its hinges, or the wall next to the door, or the floor, or ceiling...

But let's focus on the lock and key.

# A lock seems like a device that opens with a key...

Take a simple pin and tumbler lock: this seems to be a mechanical device that will only open once it detects the various bumps on the key are the correct height. A fingerprint scanner seems to be a device that measures your fingerprint and sees if it matches a stored copy of your fingerprint.

In reality, they're not.

# ...but locks are really devices which measure a key.

A pin and tumbler has pins which prevent a tumbler from rotating. The lock opens when pins inside are lifted to a specific height to allow the tumbler to rotate. So long as the height of its pins are correct it will open, no key required.

Similarly a fingerprint scanner isn't comparing fingerprints. It stores a very simplified model of your fingerprint. When it scans something, it runs it through the same algorithm to get a simplified model. So long as what it sees through its scanner results in the same model as what it has stored, it will open. No actual finger required.

# The copy only has to be as good as the lock.

It's not necessary to copy the key perfectly to open the lock. It's only necessary to fool the lock into thinking you've given it the key. All the lock-picker cares is that the lock opens. This is why you can pick locks. This is a common theme in all measurements: all measurements are indirect measurements and can be fooled.

Picking a traditional tumbler lock is all about putting the pins at the same height as the key would; you're fooling the detector. Tricking a fingerprint scanner is all about giving it something close enough to the real fingerprint that it has the same model, like a copy you lifted off something the lock owner touched.

This is important because it gives us a lot more to play with when we talk about an "uncopyable" key. We don't need to copy the key, we just need to reproduce what the lock expects to detect. This is a common theme in security: its only as good as its weakest link.

# If they key is incredibly complicated, attack the lock instead.

The lock has to measure the key, so making the key unmeasurable (and thus uncopyable) is out.

You might make the key incredibly difficult to reproduce, but the reproduction only has to be as good as the precision of the lock's measurement. Make the lock extremely precise (like measuring tiny imperfections in a crystal, as another answer proposed) and you also make it extremely complex.

Complex locks are fragile, expensive, and finicky. Make the tolerances too tight, and the lock might not work. Make the tolerances on a pin and tumbler lock too tight, and the key that gets banged around in your pocket all day won't fit. Scanning microscopic flaws in a crystal means even the smallest damage to the crystal or scanner will mean the lock won't open. Every physical lock must have some imprecision to deal with the real world and that imprecision is what allows an attacker to open the lock without the key.

All that complexity just increases the attack surface; the number of ways the lock can be attacked. And I don't mean hitting it with a hammer, I mean tricking the lock into thinking it's seen the key.

# The key tells you how to attack the lock.

It's not necessary to copy the key because you don't need the key to open the lock. The key itself tells us things about how the lock works so we can attack the lock.

For example, a picture of a normal key tells me the proper pin heights. A picture of your fingerprint tells me how to make a fake that will fool the scanner.

So, again, it's not necessary to copy the key to open the lock.

# Something Something Something Quantum

Quantum Something is going to come up when it comes to making things that cannot be copied or measured. This is moot for this scenario: you want a macroscopic physical key, not electrons, but let's go into it a bit.

A big problem in encryption is how do you distribute the encryption keys? What Quantum Entanglement brings is Quantum Key Distribution. This protects against various ways for a 3rd party to snoop on the key. Entangled particles are a single quantum system. Any measurement of a quantum system changes that system, so any snooping will change the system and that change can be detected.

While the key can be copied, you can detect it has been copied. Copying requires measurement which alters the quantum state. With a long enough key, something like 80 bits, you can detect that the key has been copied. This means you can transmit the shared key and know whether it's been intercepted. That's what quantum entanglement buys you.

• You think too much in terms of usual door locks. In the case, this statement is true "The key itself tells us things about how the lock works so we can attack the lock.", but it is because you anyway know existing types of locks(their decrypting algorithms) and how they work and what they are measuring. When you have a physical object, rich with features wich could be measured you have to guess which are important which aren't. And if it is an infinite(big) number of algorithms to guess, it is equivalent to guessing about a password. With copying key and entanglement there is a problem too. – MolbOrg May 1 '17 at 10:39
• @MolbOrg The question is about an impossible to copy physical key, not a really hard to copy key. Using an unusual type of lock or putting lots of red herrings on the key is just security through obscurity; that key still has to fit the lock, and that tells you things about the lock. It's very easy to become fascinated by all the possible permutations and think your lock is secure, but the history of lock picking (electronic and physical) is rarely about brute force. Instead, is about exploiting flaws to reduce the permutations to something manageable. – Schwern May 1 '17 at 21:39
• You say that your quantum key can be copied, but you will detect that copy was taken, I may no understand how you would like to detect that, and how you would like to use the quantum state as a key. You might improve that part of the answer. there are 2 cases - first, you know the state which was in the key and thus you know which measuring results should be. How do you know it without measuring and if you created the state why other can't create the state. Second, if you can copy entanglement, how is it no a copy of the key. – MolbOrg May 2 '17 at 13:10
• @MolbOrg Since the answer is about a physical key, Quantum Something doesn't apply. I bring it up because other people did and don't understand it. There's already a links explaining Quantum Key Distribution and how snooping is detected. When most folks talk about Quantum Encryption, they're actually talking about Quantum Key Distribution which solves the Catch 22 of key distribution. Entanglement is not part of the key, but part of the protection. – Schwern May 2 '17 at 19:28

Quantum mechanics has the “no cloning theorem”. Simply introduce the same idea for your Magic mechanics.

Have a magic pair of objects that exploit this principle, so that any attempt to duplicate the magic state of one of the objects will cause it to be scrambled. There’s no clever way around it because it's axiomatic in your magic’s rules.

Using the key might also destroy it, making it a one-time-use key/lock pair. The mechanism might reset the internal device and key at this time, generating a fresh matched pair. So, the key is different on each use, but this is transparent to the user. Or, the act of checking that the two objects match, without revealing what their state actually is, does not destroy it.

• Problem here is the key can only be used once, if at all. Observing it would change its quantum state, including checking if it's the correct key. – Schwern Apr 30 '17 at 18:41
• @Schwern updated to address that. – JDługosz Apr 30 '17 at 21:36
• Creating a new key pair on successful use is clever. As for the second part, AFAIK you can't check if they match without observation. – Schwern May 1 '17 at 0:24
• @Schwern «can’t…» maybe with your magical rules you can’t, but with mine you can. (Actually, match checking could change the state (of both) and you would never know. So it's really the first case again.) – JDługosz May 1 '17 at 1:05

## EASY: Key is made on demand and usable only once

In the post, the OP says that the lock can be magical, but not the key.

The OP wants a key that cannot be copied.

SOLUTION: Self-re-programming lock, throw away keys.

In the REAL WORLD:

Passwords that become invalid each time you use them.

In the FANTASY WORLD:

The backside of the secret door contains the layout of the shape/size/material of the key to be used to unlock it - materials that are near the door (perhaps part of the wall, floor, etc).

The "key" then, is the knowledge of how to make the key to unlock it - i.e. the "password".

The user then makes the key at the door and unlocks the door. When that happens, the magical lock re-configures, displaying a new key shape and material to be used for the next key. The current key is then useless.

To prevent duplication, don't make the key until you are at the door.

Only the person successfully opening the door would get the correct blueprint for the next key. If they did not know to look for the next blueprint, then the door is effectively locked forever once they shut the door.

It isn't clear to me what you are asking.

If the only thing the "thief" has is the indentation, then picture the indentation in which a disk would fit. Lets say that there are 100 pins in the door which fit into 100 holes in the sides of the disk. If the range of pin lengths/hole depths is such that say there are 5 "different" lengths, then there are 5100 possible combinations.

If the mechanism takes, say, 1 minute to cycle through an attempted unlock process, then it would take about 1058 years to have a 1-in-a-million chance to "get lucky" with a random configuration of holes. (One trick I'm using here is that the mechanism can't be "attacked" sequentially, which is the way the typical tumbler & pin lock is picked. It's an "all or nothing" type lock. The mechanism for that would be complicated, justifying a long-ish opening cycle.)

So, the only way to copy the key is to have either possession of it, or fairly accurate measurements of its size as well as the depths of the holes. Could it be copied? Sure, but even if the copier had a portable "indentation" with pins which would record the hole depth for each of the holes, the copier would have to have physical possession of the key for long enough to use the copier (same is true of photographing or otherwise measuring the holes' depth).

But if the copier can access the key, then why not just use the original? If the key is kept somewhere that insecure, then why bother copying it? If its possible for a copier to get physical possession of the key for only a short time, then the question is one of technological reverse engineering.

Say some of the holes have an electrical or magnetic or acoustic or fluidic circuit from one hole to others. And say there are 20 of those connecting two or more holes. How would the copier know that in order to copy it? Each possiblity would have to be tested.

You could imagine all sorts of requirements to make it difficult to copy. Difficult as in time consuming. Difficult as in requiring a lab. And as I already said, if you can take the key to a lab and spend hours and hours studying it, then you may as well just steal it.

• Could you edit this to make it easier to read? Otherwise it looks good. – can-ned_food Apr 29 '17 at 2:35

The way to unlock this archaic door? A strangely shaped stone. By placing it into the indent, the vault opens.

Scenario: no advanced technology, therefore no sufficiently advanced technology to be called magic (otherwise we could bury inside the stone a military-grade tamperproof RFID crypto transceiver and call it a day).

In the "low tech, but high security" scenario we can't make an uncopyable key, but we can build a lock that needs more than a copied key - it requires knowledge. The key plus the knowledge could be thought uncopyable, if the very existence of that knowledge is kept secret.

The lock is free to rotate (i.e., the bevel where the indented stone is to be placed is round, and can rotate just as a lock can do when the correct key is in).

The correct indentation - which can be supplemented by e.g. magnetic coupling between the "lock" and several parts of the "key", which can be made half of copper, half of magnetic iron ore - engages a sliding pin, and now the rotation will move, say, three disks inside the lock, working like a safe's disc combination lock.

With the correct "key" or a good enough copy in, you also need to give it three turns sunwise and stop at a precise position, two turns widdershins and stop at another position, one turn sunwise... and only when finished can you push on the "key" and, if the combination was correct, the "lock" will be free to go inwards -- and that will open the door.

If you don't have the correct key, or you do not know the correct combination, the last part won't happen. But you will not be able to verify whether the key is correctly made, since also a bad key will allow rotation.

Brute force attacks can be thwarted by having the final "pressure" on the lock engage a piston before going fully in. Then, the lock does not reset until the piston returns to its rest position. Several mechanisms are available to make sure that this only happens after a suitable time. One could also use a simple ratchet counter, so that after a set number of incorrect attempts, the delay is increased (for example, one of the two weights returning the piston to the rest position is removed). Finally, instead of resetting the lock, the system could simply make it so the pin does not engage at all, so that no combination is correct. At that point you need to either know the combination, or know the lock reset times: otherwise, not only your only resort is brute force, but even that might avail you nothing - after days of bruteforcing, you have tried all the possible combinations, and none works.

To add confusion to the mix, and avoid keen-eared thiefs from figuring out the combination by hearing the pin slide and hit the stops, you can also install inside the outermost ring some broken springs and bits of rust.

Most people would hear the rasping metallic sounds, notice that the lock can rotate freely and yet nothing happens, and conclude "Darn. It's been broken. Now it probably can't be opened anyway".

• "turnwise" and "widdershins". Not "sunwise" and "widdershins". – wizzwizz4 May 1 '17 at 8:22
• Sorry for the confusion, @wizzwizz4 , I was not referring to the Disc. On Earth, sunwise is the correct turn of phrase. See en.wikipedia.org/wiki/Sunwise . – LSerni May 1 '17 at 9:32

One way is if you made it out of something that radioactively decayed in a very predictable but unique way, and have a sensor in the door that can detect it.

So the elements in the key decay. You slide it in and the door reads it, decides that it matches, and unlocks.

If you made a copy using the same elements, it would be impossible to find samples that were decaying in exactly the same way, and so they wouldn't match.

Using magic only you could maybe do it with crystal vibrations or something that is slowly changing over time in a way that the magic can anticipate.

• Any physical mechanism that you can design, someone else can copy. You can only make it complex to copy, not impossible. – StephenG Apr 28 '17 at 18:24
• @StephenG It's not the complexity, but the randomness. It's like those yubikeys or other two auth devices that cycle in a random manner, but which is predicable. Two pieces of radioactive ore probably wouldn't decay in exactly the same way. Now take multiple slices to make the key, each decaying at a different rate, and the amount of randomness becomes incalculable. – AndyD273 Apr 28 '17 at 18:29
• It would NOT be impossible to reproduce matching isotope ratios -- especially if the people making the copy have the same tech as you do. – Catalyst Apr 28 '17 at 18:40
• But nigh-impossible is, for all intents and purposes, impossible. The way radioactive ores decay is truly random, and as such, a key made up of multiple ores would be (nigh) impossible to copy. – Sirama Apr 28 '17 at 18:51
• @Andy, The point is that it ISN'T RANDOM, it's statistical and predictable,every isotope in the mix. All isotopes follow exponential decay curves. If the isotopes are available (that is, you haven't used up the entire planetary supply in the first key.) With the right lab gear (e.g. isotope separation gear like gas centrifuges) it can be reproduced. I've worked in high energy physics professionally (including an experiment that used the main beam line at Brookhaven); have you? – Catalyst Apr 28 '17 at 18:55

Nothing is impossible to copy. All you can do is make it harder to copy.

If you make it difficult enough, it may cost more to copy the key than you get from using the key.

The reason for most locks is mostly to say: this won't be easy, go break into the home/car/etc. of someone who is an easier target.

Even if you allow magic for making the key/lock, you have to allow magic for bypassing the lock.

Make a key with internal element !

The key will be a kind of box. The door will open the key, and will be unlock by the internal elements. It make the key impossible to copy without the door.

I don't really know how to build that, but I think this is possible.

Let's separate the components of the problem. We'll make a non-magic purely physical world key, and a magic lock to read the key.

The key will be made by embedding many hundreds of small crystals (garnet, amethyst, ruby, diamond and so on) into a simple molten glass melt formed into a cylinder. The key is essentially random; they made the key, then adjusted the lock so that key alone opens it.

When the key is inserted, the magic lock shines magical lights of different colours from different angles all around the outside into the key, which bounce off the crystals, and the lock magically measures the output light signal at certain positions. When the correct combination of light measurements is obtained, the key is valid.

Using this approach, anyone looking at the lock gains no information about what type of thing or configuration is required to activate the lock.

Even if you had the key in front of you - perhaps in a display case - you could never copy it. The output of the light beams bouncing off the many crystals is critically sensitive to the exact 3-D shape, size, position, overlap, colour, internal flaws, and orientation, of the many hundreds of tiny crystals. A tiny mismatch of any dimension will be magnified by internal reflections into a non-valid output.

This has nice aesthetics for a magical campaign - the key doesn't look like a 'key', but it does look special. And whenever anything is put in the 'lock' there is a nice magical light show.

### Refraction

Not only does the key have to be shaped correctly and of the correct mass, it has to refract light the same way. The lock accepts the key, rotates it to match the correct placement, and then shines light through it. If the light refracts through the gem in the correct way, with the right color changes, the door opens.

This even has some precedent in fantasy. Remember the scene in the Hobbit? They place the key and then have to wait for just the right time for the light to shine such that the lock is triggered and they can go through. You don't have to use a super secret time if the lock can generate light itself.

This works because refraction is more individual than shape. It is based on characteristics of the inside of the gem. Sure, you can make another diamond of the same shape and weight, but the color and direction of refraction is going to be slightly different. The lock should be able to detect such differences.

If the gem itself can't be copied by magic (because it is an anti-magic material or because magic would leave a signature that the lock would recognize), then the key is unique. The lock was built to match the key. The key may have been shaped, but its real uniqueness was the randomness of its natural creation.

I prefer that the key be made of a naturally anti-magic material. Since that would prevent the key from being copied exactly, it seems rather foolproof.

If the lock detects material made by magic copying, then someone could make the key not work by casting magic on it. Also, it seems possible that someone would find a way to remove the magic traces. Then the whole system falls apart. Of course, that might be a useful plot point...

An in-universe approach could be using an extinct (preferable to rare), unfaceted crystal with an ultra high hardness (think a diamond) which is made of two matching halves and is incorporated into the gate/wall/safe.

Now for the additional complexity of the lock :

1. Due to its crystalline properties this material cannot be replicated in nature or forged by your population. All crystals created by natural circumstances are different.
2. Both halves having an ultra-refined uniquely-matching contact face pattern which occurred naturally by breakage, either by magic or force-majeure considering the history of your environment.
3. On contact both faces match not only by the physical face but also by the physical hardness meaning another material will break when the needed force is applied. This also prevents it being picked by molding/casting.
4. The lock would be opened by a tremendous physical force/effort, either by applying that physical force either radially, vertically or horizontally.
5. You can use the frequency of crystals creatively as in providing a second scan pattern, it could be triggering anything from light to melody to magic.
6. You can be much more creative with the frequency and energy that could be transmitted/transferred with a crystal to your universe, for example it could be linked with the frequency a specific brainwave as in channelling a thought by a specific character to the lock as an extra lock scan.

That's pretty much the tip of it, I suggest you have a read about crystals and their properties to get an idea how you can extend the lock's safety and the creativity of your lock. Some inspirational links:

Have fun and be creative!

• Now this, my friend, is a truly great answer. Crystals aren't something I had really thought about, but this gives a far superior explanation of their uses to other answers. – Sirama Apr 30 '17 at 0:19

As others have said, it's impossible to make a key that can't be copied. However, that's not what you are asking for here. You have a keyhole and want to keep someone from manufacturing a key that fits it--the counterfeiter doesn't have a key to copy.

While you can't make your lock unpickable you can go a lot farther. The indentation is merely for guidance, the "key" contains a bunch of magnets. These pull on the pins in the lock--and you must only lift the correct pins. The number of possible patterns is 2^(number of pins). Use enough pins and the lock will have crumbled to dust over the ages before the counterfeiter hits on the right combination.

The reason that only the oddly shaped stone opens the lock is because there are powerful magnets hidden at irregular places under the surface of the stone, which either attract or repulse pins hidden under the surface of the lock. Even knowing this, the key is difficult to reverse-engineer.

The shape of the key is crucial to align the magnets, but is otherwise irrelevant to the actual unlocking.

The advantage to this system is it matches the observed behavior --the stone and only the stone unlocks the door --without requiring too much in the way of advanced science to create it. The hardest parts would be obtaining strong enough permanent magnets, and then concealing them under the surface.

• Like the RFID chip found in many door keyless entry systems today! – CaM May 1 '17 at 18:43

The key contains an encrypted computer chip of some kind.

You can copy the shape all you want, but without the data stored inside your lock does nothing. The lock provides power, but the power levels change and only the original keys knows the right responses.

The circuits are delicate so any attempt to copy it could destroy the original.

The conductors have to be in the exact right spots in the key to pass the current around. Also decoy conductors that do nothing, or detect damage/copying and de-activate the key.

Another suggestion, the actual key doesn't fill the whole lock, and anything that fills the whole lock will be a dead give away to the lock what your doing. People will assume the key was broken into pieces and scatted for security, when actually it wasn't. Some many spend entire life times searching for missing fragments.

You asked about physical copy protection for a key with no magic.

To even begin to copy a key you need to make it so it isn't just shape dependent.

1. public key/private key computer chip inside key.
2. Wires, embedded into the key made of different materials which conduct current better/worse than others. There would be a series of 100+ conductors on the surface of the lock, and the real key would have a specific pattern,including decoys, in it.
3. The correct key should not fill the whole lock! Any attempt to fill the whole should be a hack attempt and de-activate the lock for a month(or some penalty). Maybe crush your fake key.

Beyond looking at the locks shape, and possibly scanning the lock the fake key maker would have no idea the key contained a chip. They maybe be able to detect wires in the lock, but they will have no idea which ones are input,output, fakes, or trojans. They could probably detect the types of metal wires in the lock, but the key could have dis-similar metals touching on purpose.

Even 20 years ago we had basic computer memory chips, and the chip could be embedded into the middle of the key, and contain 32768 bit key(or whatever you want).

----Prisms/light If you want to remain relatively primitive, as in no computer chips. Use glass and/or diamonds for prisms. The edges of the key will have tiny holes to let light in. Say 100 of them, for example.

Unless you physically have the key you won't be able to copy it. You won't know which holes are input, outputs, fakes, dead ends, or etc.

Each hole will have different color refactors. You input blue here and yellow there, and a specific shade of green comes out. That green light is then mixed with other input sources. At different stages, you will have output pegs, where the lock checks the correct colors are coming out.

-------------basic keyboard A key that contains buttons to push. The buttons on the key extend or retract metal rods to various lengths or positions.

Sure you copied the key, but of 100 buttons, which ones in which combination need to be pressed and how far.

• Ancient civilizations don’t have computer chips. I don’t think 20 years ago qualifies as ancient. – JDługosz May 1 '17 at 6:23
• @JDługosz Thus, cryptographic behavior of the key object would have to be classified as an example of "any sufficiently advanced technology indistinguishable from magic". – Kaz May 1 '17 at 21:20
• @JDługosz You assume ancient = primitive. However, advanced civilization can evolve, and either A die off or B move to another planet/solar system. Even a civilization 2x advance as use can be ancient if our civilization lasts 10's of thousands of years. – cybernard May 1 '17 at 21:22

As others pointed out, a completely uncopyable key is effectively impossible. Shuffle a deck of cards, and there are 52! combinations, which is a Massive number. It is still entirely possible to shuffle a deck twice, and have the resulting deck be in the exact same order. If it can exist, it can be duplicated, from DNA to fingerprints. The only way around it is Magic that specifically says it cant be duplicated, which even in a Magic world makes almost no sense. Removing magic as a factor, all you can do is make it as complicated as possible.

That being said, one of the most complicated physical systems would be a mechanical/clockwork device and key. Using gears and such, a device which while turning also changes shape would not look like a key normally, and also due to its mechanical nature means that you cant just copy it. Its complexity would prevent all but advanced clockwork mechanics from even understanding how it works, and anyone else messing with it would probably break it.

If it opened like a star as it turned, but also had other protrusions, all of which need to rotate with and/or against the door as the key turns in order to solve the maze like lock, then you could be pretty sure that only a few people could ever copy it without breaking it. If the lock also required multiple points of contact to turn, and was irregularly shaped, then it could be rendered near impossible to pick without several people and specialized tools that probably wouldn't exist normally. At that point, its easier to flat out break the door down, or go around through the rock.

As the story of Brahm of League of legends goes. He couldn't get past a indestructable door to save a troll child, so he used his fists to punch a hole through the mountain around the door. That will probably be the way someone gets past the door if it gets this complex and is strong.

In the comments, I noted that if the lock itself is allowed to be magical, simply have that magic specify that the real Amulet of McGuffin be used. Magic can definitely do this, because, hey, it is magic. In this story trope, it is almost always one of two things: any object in the right spot would work, if you know, or it's this: the spell requires the right object, and isn't fooled be substitution.

However, if that doesn't feel satisfyingly specific enough, how about: the magic can detect the age of the item — specifically, the time of its manufacture. Since it's magic, this can't be fooled, and it can't be copied without time travel.

I know another answer already mentions age as one of a number of possible factors, but I think it's actually completely sufficient alone.

The key is copyable, but you still need to know how to penetrate the vault.

Consider the design of ancient citadels (pre-gunpowder). The gates lead into a narrow tunnel, beyond which is another gate. The very thick walls are pierced with small holes through which the defenders can fire arrows and thrust spears., and the equally thick ceiling with holes through which the defenders can pour burning oil or acid.

You may break down the first gates, but you will never breach the second set. Should enough crazy men try, the tunnel will soon be jammed with corpses.

So to this vault. We already have granted, that the walls are magically unbreachable. The key can be copied, but what a copied key grants you is access to what is effectively an airlock. In front of you is another similar door, a large array of small holes, a supply of pegs that clearly fit in the holes, and (maybe) some mummified corpses or skeletons.

Do you feel lucky?

You may work out that you must enter, close the vault door behind yourself, and then insert the right number of pegs into the right holes. You can then attempt to proceed through the second door. But what other things must be done, to avoid or disarm the trap?

In fact, the key that you have a copy of, is actually there in the interests of not slaughtering the merely curious. The real lock is a combination mechanism, on the far side of impenetrable walls, possibly with added lethal traps. A modern man will recognise this as not dissimilar to the PIN he types into his ATM, but built in times when a wannabe thief's life was less highly valued. Security 101: "Something you have, and something you know". You have, but you do not know. An ancient would more immediately recognise the similarity to the entrance to a citadel.

As an added twist, maybe there is a large wheel on the outside, which requires very considerable force to turn against a ratchet. You are clearly storing a large amount of energy into a large spring of some sort. The outer door will not unlock unless the mechanism is wound. Sudden release of this energy is clearly how you will die, if you decide to play this lottery.

You consider donning some very strong modern armour, but surely a civilisation that could create magically unbreachable walls would have considered the possibility of magically unbreachable armour? You may conclude that the threatened rapid death by sharp steel was not vengeful but a mercy to the merely suicidally impetuous thief. Starvation, or something magically worse, awaits the well-armoured thief. The door through which you enter, will not unlock again until you have proceeded through the inner door, or until you have drawn your last breath.

[only the detection of last breath requires magic. A combined citadel entrance, spring-driven man trap and combination lock, is well within the reach of a renaissance engineer and a civilisation with good metalworking skills]

Under your limitations there is no way how to prevent a key and lock from being compromised. Once it is identified as a lock or key there is a way how to prepare a forged key.

The only way is to prevent anyone from understanding that that strange stone is a key and this tiny hole is a lock.

For example, have a long corridor with many ancient statues. Part of them are locks and you have to put keys (pieces of a wand, gems) in their mouths, eyes and ears.

You can use any natural detail to hide the true function of the lock and you can use amulets to hide their key purpose in "just a decoration".

Asymmetric Key Lock

Simple, the key which locks the Mechanism(M) is different from the key which opens it. After it has been used for opening, it becomes the new "Lock" key.

Only the lock key protrudes the Opening Mechanism (O): after O has been inserted in a locked M and the lock key (currently protruding ) is verified, the unlock key protrudes and unlocks M while the lock key draws back.

Alltogether O,M have n such keys at any time, n-2 are stand by n-1th is unlocking and the nth protruding one is locking, which changes at every lock/unlock.

Atleast for first n lock/unlocks the system is fully secure

• How’s that asymmetric ? It’s a single use key that prevents replay attacks. But the current key could be copied and the copy used, which then locks out the original holder. – JDługosz Apr 29 '17 at 16:30
• single use key Is the same isea as Prinz’s answer. Your scheme is automatic, the other turns it into a password instead. – JDługosz Apr 29 '17 at 16:33
• @JDługosz asymmetric as the key which locks is different from the key which unlocks. User can always open a lock put by current protrusion..( also generally the problem will be to prevent unauthorised 'opening' of lock) Prinz;s answeris vulnerable to copying of the new key info - while being displayed, while in posessionof the user or as a key. – ARi Apr 29 '17 at 17:14

If you are the creator of this world and things like magic exist, then you can make fictional additions to create effects you want. Since you seem to want a plain oldschool idea of a key the most suitable solution in my opinion is the following:

The key for this door can be of plain, copyable shape. That is something you cannot avoid. However the element used to create this key can be unique. If the order that guards the temple has used a specific alloy or metal of greater strength and density than any other metal in your earth, and assuming it came from a meteor for example, to create both the lock and the key then it becomes impossible to copy. Where does a different extraterrestrial metal help? Locks are made so that they have pins and edges that a key's shape is supposed to push and turn. If the lock breaks any type of key except one made of equal material strength then only your unique key can open it.

Simple and old fashioned solution with a little bit of salt for the story

Both key and lock mutate each time they are used. Any attempt to read the key causes it to mutate, throwing it out of phase with the lock, making it useless. You didn't specify if the key had to be recoverable, so I assumed no.

The problem can be solved by requiring knowledge. First, to keep this real, the key is nothing but a fancy square bar. one end goes into a socket within the lock. The keyholder turns the key until a gear pulls a bar from the door frame. We know this is doable at the tech level.

Now imagine the key has holes in it. There are rods that drop in the holes. Part of the lock mechanism includes levers that can lift rods... Or push rods up from underneath. Some levers could serve as a type of clutch to inhibit or augment some of other levers' behavior.

This is some weird cross between a normal tumbler lock and combination lock.

I am certain I could build one. I assume a motivated skilled ancient could also.

I'd add a bell or chime to the inside of the lock so as the key was turned it would make noise.

I could see the 'combination' would have 64 possibilities. So the bell could be ringing quite a lot. After a few extra rings, the caretakers could investigate.